From 01bdec059d2a656c2e04182e41ec2c3d3f6d2cd4 Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Thu, 26 Sep 2024 10:16:07 +0100 Subject: [PATCH] chore: regenerated code --- src/v2/generated/.openapi-generator/FILES | 12 -- src/v2/generated/models/Attendee.ts | 2 +- .../generated/models/AuthenticationError.ts | 6 +- .../generated/models/AuthenticationErrors.ts | 4 +- src/v2/generated/models/AuthorizationError.ts | 6 +- .../generated/models/AuthorizationErrors.ts | 4 +- src/v2/generated/models/ChatMessage.ts | 9 +- src/v2/generated/models/CompaniesValue.ts | 13 +-- src/v2/generated/models/Company.ts | 2 +- src/v2/generated/models/CompanyData.ts | 2 +- src/v2/generated/models/CompanyListEntry.ts | 11 +- src/v2/generated/models/CompanyPaged.ts | 2 +- src/v2/generated/models/CompanyValue.ts | 11 +- src/v2/generated/models/ConflictError.ts | 49 -------- src/v2/generated/models/DateValue.ts | 11 +- src/v2/generated/models/Dropdown.ts | 2 +- src/v2/generated/models/DropdownValue.ts | 11 +- src/v2/generated/models/DropdownsValue.ts | 13 +-- src/v2/generated/models/Email.ts | 15 +-- .../generated/models/EmptyMessageBodyError.ts | 49 -------- src/v2/generated/models/Errors.ts | 39 ------- src/v2/generated/models/Field.ts | 2 +- src/v2/generated/models/FieldMetadata.ts | 2 +- src/v2/generated/models/FieldMetadataPaged.ts | 2 +- src/v2/generated/models/FieldValue.ts | 2 +- src/v2/generated/models/FloatValue.ts | 11 +- src/v2/generated/models/FloatsValue.ts | 13 +-- src/v2/generated/models/FormulaNumber.ts | 2 +- src/v2/generated/models/FormulaValue.ts | 11 +- src/v2/generated/models/GenericError.ts | 49 -------- src/v2/generated/models/Grant.ts | 11 +- src/v2/generated/models/Interaction.ts | 2 +- src/v2/generated/models/InteractionValue.ts | 11 +- .../models/InvalidAcceptHeaderError.ts | 49 -------- .../models/InvalidMessageBodyError.ts | 49 -------- .../models/InvalidVersionHeaderError.ts | 49 -------- src/v2/generated/models/List.ts | 2 +- src/v2/generated/models/ListEntry.ts | 2 +- src/v2/generated/models/ListEntryPaged.ts | 2 +- .../generated/models/ListEntryWithEntity.ts | 2 +- .../models/ListEntryWithEntityPaged.ts | 4 +- src/v2/generated/models/ListPaged.ts | 2 +- src/v2/generated/models/ListWithType.ts | 2 +- src/v2/generated/models/ListWithTypePaged.ts | 2 +- src/v2/generated/models/Location.ts | 2 +- src/v2/generated/models/LocationValue.ts | 11 +- src/v2/generated/models/LocationsValue.ts | 13 +-- src/v2/generated/models/Meeting.ts | 11 +- .../generated/models/MethodNotAllowedError.ts | 49 -------- src/v2/generated/models/ModelError.ts | 72 ------------ src/v2/generated/models/NotFoundError.ts | 6 +- src/v2/generated/models/NotFoundErrors.ts | 4 +- src/v2/generated/models/ObjectSerializer.ts | 105 ++++-------------- src/v2/generated/models/Opportunity.ts | 2 +- .../generated/models/OpportunityListEntry.ts | 11 +- src/v2/generated/models/OpportunityPaged.ts | 2 +- .../generated/models/OpportunityWithFields.ts | 2 +- src/v2/generated/models/Pagination.ts | 2 +- src/v2/generated/models/Person.ts | 2 +- src/v2/generated/models/PersonData.ts | 2 +- src/v2/generated/models/PersonListEntry.ts | 11 +- src/v2/generated/models/PersonPaged.ts | 2 +- src/v2/generated/models/PersonValue.ts | 11 +- src/v2/generated/models/PersonsValue.ts | 13 +-- src/v2/generated/models/PhoneCall.ts | 11 +- src/v2/generated/models/RankedDropdown.ts | 2 +- .../generated/models/RankedDropdownValue.ts | 11 +- src/v2/generated/models/RateLimitError.ts | 49 -------- src/v2/generated/models/SavedView.ts | 2 +- src/v2/generated/models/SavedViewPaged.ts | 2 +- src/v2/generated/models/ServerError.ts | 49 -------- src/v2/generated/models/Tenant.ts | 2 +- src/v2/generated/models/TextValue.ts | 2 +- src/v2/generated/models/TextsValue.ts | 13 +-- .../models/TooManyMultipartFilesError.ts | 49 -------- src/v2/generated/models/User.ts | 2 +- src/v2/generated/models/ValidationError.ts | 8 +- src/v2/generated/models/ValidationErrors.ts | 4 +- src/v2/generated/models/WhoAmI.ts | 2 +- src/v2/generated/models/all.ts | 12 -- src/v2/generated/types/ObjectParamAPI.ts | 12 -- src/v2/generated/types/ObservableAPI.ts | 12 -- src/v2/generated/types/PromiseAPI.ts | 12 -- 83 files changed, 156 insertions(+), 989 deletions(-) delete mode 100644 src/v2/generated/models/ConflictError.ts delete mode 100644 src/v2/generated/models/EmptyMessageBodyError.ts delete mode 100644 src/v2/generated/models/Errors.ts delete mode 100644 src/v2/generated/models/GenericError.ts delete mode 100644 src/v2/generated/models/InvalidAcceptHeaderError.ts delete mode 100644 src/v2/generated/models/InvalidMessageBodyError.ts delete mode 100644 src/v2/generated/models/InvalidVersionHeaderError.ts delete mode 100644 src/v2/generated/models/MethodNotAllowedError.ts delete mode 100644 src/v2/generated/models/ModelError.ts delete mode 100644 src/v2/generated/models/RateLimitError.ts delete mode 100644 src/v2/generated/models/ServerError.ts delete mode 100644 src/v2/generated/models/TooManyMultipartFilesError.ts diff --git a/src/v2/generated/.openapi-generator/FILES b/src/v2/generated/.openapi-generator/FILES index f5e0c11..b45725e 100644 --- a/src/v2/generated/.openapi-generator/FILES +++ b/src/v2/generated/.openapi-generator/FILES @@ -31,14 +31,11 @@ models/CompanyData.ts models/CompanyListEntry.ts models/CompanyPaged.ts models/CompanyValue.ts -models/ConflictError.ts models/DateValue.ts models/Dropdown.ts models/DropdownValue.ts models/DropdownsValue.ts models/Email.ts -models/EmptyMessageBodyError.ts -models/Errors.ts models/Field.ts models/FieldMetadata.ts models/FieldMetadataPaged.ts @@ -47,13 +44,9 @@ models/FloatValue.ts models/FloatsValue.ts models/FormulaNumber.ts models/FormulaValue.ts -models/GenericError.ts models/Grant.ts models/Interaction.ts models/InteractionValue.ts -models/InvalidAcceptHeaderError.ts -models/InvalidMessageBodyError.ts -models/InvalidVersionHeaderError.ts models/List.ts models/ListEntry.ts models/ListEntryPaged.ts @@ -66,8 +59,6 @@ models/Location.ts models/LocationValue.ts models/LocationsValue.ts models/Meeting.ts -models/MethodNotAllowedError.ts -models/ModelError.ts models/NotFoundError.ts models/NotFoundErrors.ts models/ObjectSerializer.ts @@ -85,14 +76,11 @@ models/PersonsValue.ts models/PhoneCall.ts models/RankedDropdown.ts models/RankedDropdownValue.ts -models/RateLimitError.ts models/SavedView.ts models/SavedViewPaged.ts -models/ServerError.ts models/Tenant.ts models/TextValue.ts models/TextsValue.ts -models/TooManyMultipartFilesError.ts models/User.ts models/ValidationError.ts models/ValidationErrors.ts diff --git a/src/v2/generated/models/Attendee.ts b/src/v2/generated/models/Attendee.ts index 9aaa3ad..066fd95 100644 --- a/src/v2/generated/models/Attendee.ts +++ b/src/v2/generated/models/Attendee.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/AuthenticationError.ts b/src/v2/generated/models/AuthenticationError.ts index b9e388b..a24c1c3 100644 --- a/src/v2/generated/models/AuthenticationError.ts +++ b/src/v2/generated/models/AuthenticationError.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -16,11 +16,11 @@ export class AuthenticationError { /** * Error code */ - 'code'?: string | null; + 'code': string; /** * Error message */ - 'message'?: string | null; + 'message': string; static readonly discriminator: string | undefined = undefined; diff --git a/src/v2/generated/models/AuthenticationErrors.ts b/src/v2/generated/models/AuthenticationErrors.ts index 9ed0150..b855524 100644 --- a/src/v2/generated/models/AuthenticationErrors.ts +++ b/src/v2/generated/models/AuthenticationErrors.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -20,7 +20,7 @@ export class AuthenticationErrors { /** * AuthenticationError errors */ - 'errors'?: Array | null; + 'errors': Array; static readonly discriminator: string | undefined = undefined; diff --git a/src/v2/generated/models/AuthorizationError.ts b/src/v2/generated/models/AuthorizationError.ts index 6451aae..43a2b27 100644 --- a/src/v2/generated/models/AuthorizationError.ts +++ b/src/v2/generated/models/AuthorizationError.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -16,11 +16,11 @@ export class AuthorizationError { /** * Error code */ - 'code'?: string | null; + 'code': string; /** * Error message */ - 'message'?: string | null; + 'message': string; static readonly discriminator: string | undefined = undefined; diff --git a/src/v2/generated/models/AuthorizationErrors.ts b/src/v2/generated/models/AuthorizationErrors.ts index dd3f047..9fbc118 100644 --- a/src/v2/generated/models/AuthorizationErrors.ts +++ b/src/v2/generated/models/AuthorizationErrors.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -20,7 +20,7 @@ export class AuthorizationErrors { /** * AuthorizationError errors */ - 'errors'?: Array | null; + 'errors': Array; static readonly discriminator: string | undefined = undefined; diff --git a/src/v2/generated/models/ChatMessage.ts b/src/v2/generated/models/ChatMessage.ts index 57a9e9e..ad00779 100644 --- a/src/v2/generated/models/ChatMessage.ts +++ b/src/v2/generated/models/ChatMessage.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,7 +17,7 @@ export class ChatMessage { /** * The type of interaction */ - 'type': ChatMessageTypeEnum; + 'type': string; /** * The chat message\'s unique identifier */ @@ -44,7 +44,7 @@ export class ChatMessage { { "name": "type", "baseName": "type", - "type": "ChatMessageTypeEnum", + "type": "string", "format": "" }, { @@ -86,9 +86,6 @@ export class ChatMessage { } } -export enum ChatMessageTypeEnum { - ChatMessage = 'chat-message' -} export enum ChatMessageDirectionEnum { Received = 'received', Sent = 'sent' diff --git a/src/v2/generated/models/CompaniesValue.ts b/src/v2/generated/models/CompaniesValue.ts index 3bb94f7..bee377d 100644 --- a/src/v2/generated/models/CompaniesValue.ts +++ b/src/v2/generated/models/CompaniesValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,11 +17,11 @@ export class CompaniesValue { /** * The type of value */ - 'type': CompaniesValueTypeEnum; + 'type': string; /** * The values for many companies */ - 'data': Array | null; + 'data': Array; static readonly discriminator: string | undefined = undefined; @@ -31,7 +31,7 @@ export class CompaniesValue { { "name": "type", "baseName": "type", - "type": "CompaniesValueTypeEnum", + "type": "string", "format": "" }, { @@ -48,8 +48,3 @@ export class CompaniesValue { public constructor() { } } - -export enum CompaniesValueTypeEnum { - CompanyMulti = 'company-multi' -} - diff --git a/src/v2/generated/models/Company.ts b/src/v2/generated/models/Company.ts index 729450b..17be6a2 100644 --- a/src/v2/generated/models/Company.ts +++ b/src/v2/generated/models/Company.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/CompanyData.ts b/src/v2/generated/models/CompanyData.ts index 9963028..3e381d0 100644 --- a/src/v2/generated/models/CompanyData.ts +++ b/src/v2/generated/models/CompanyData.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/CompanyListEntry.ts b/src/v2/generated/models/CompanyListEntry.ts index b73ef76..444fa01 100644 --- a/src/v2/generated/models/CompanyListEntry.ts +++ b/src/v2/generated/models/CompanyListEntry.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -21,7 +21,7 @@ export class CompanyListEntry { /** * The entity type for this list entry */ - 'type': CompanyListEntryTypeEnum; + 'type': string; /** * The date that the list entry was created */ @@ -46,7 +46,7 @@ export class CompanyListEntry { { "name": "type", "baseName": "type", - "type": "CompanyListEntryTypeEnum", + "type": "string", "format": "" }, { @@ -75,8 +75,3 @@ export class CompanyListEntry { public constructor() { } } - -export enum CompanyListEntryTypeEnum { - Company = 'company' -} - diff --git a/src/v2/generated/models/CompanyPaged.ts b/src/v2/generated/models/CompanyPaged.ts index 53d6640..0336cec 100644 --- a/src/v2/generated/models/CompanyPaged.ts +++ b/src/v2/generated/models/CompanyPaged.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/CompanyValue.ts b/src/v2/generated/models/CompanyValue.ts index da6ae9a..aaa1fa8 100644 --- a/src/v2/generated/models/CompanyValue.ts +++ b/src/v2/generated/models/CompanyValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,7 +17,7 @@ export class CompanyValue { /** * The type of value */ - 'type': CompanyValueTypeEnum; + 'type': string; 'data': CompanyData | null; static readonly discriminator: string | undefined = undefined; @@ -28,7 +28,7 @@ export class CompanyValue { { "name": "type", "baseName": "type", - "type": "CompanyValueTypeEnum", + "type": "string", "format": "" }, { @@ -45,8 +45,3 @@ export class CompanyValue { public constructor() { } } - -export enum CompanyValueTypeEnum { - Company = 'company' -} - diff --git a/src/v2/generated/models/ConflictError.ts b/src/v2/generated/models/ConflictError.ts deleted file mode 100644 index 2113fe6..0000000 --- a/src/v2/generated/models/ConflictError.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. - * - * OpenAPI spec version: 2.0.0 - * Contact: support@affinity.co - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { HttpFile } from '../http/http.ts'; - -export class ConflictError { - /** - * Error code - */ - 'code'?: string | null; - /** - * Error message - */ - 'message'?: string | null; - - static readonly discriminator: string | undefined = undefined; - - static readonly mapping: {[index: string]: string} | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ - { - "name": "code", - "baseName": "code", - "type": "string", - "format": "" - }, - { - "name": "message", - "baseName": "message", - "type": "string", - "format": "" - } ]; - - static getAttributeTypeMap() { - return ConflictError.attributeTypeMap; - } - - public constructor() { - } -} diff --git a/src/v2/generated/models/DateValue.ts b/src/v2/generated/models/DateValue.ts index b9e6545..498cd5b 100644 --- a/src/v2/generated/models/DateValue.ts +++ b/src/v2/generated/models/DateValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -16,7 +16,7 @@ export class DateValue { /** * The type of value */ - 'type': DateValueTypeEnum; + 'type': string; /** * The value for a date */ @@ -30,7 +30,7 @@ export class DateValue { { "name": "type", "baseName": "type", - "type": "DateValueTypeEnum", + "type": "string", "format": "" }, { @@ -47,8 +47,3 @@ export class DateValue { public constructor() { } } - -export enum DateValueTypeEnum { - Datetime = 'datetime' -} - diff --git a/src/v2/generated/models/Dropdown.ts b/src/v2/generated/models/Dropdown.ts index 447983b..ba98219 100644 --- a/src/v2/generated/models/Dropdown.ts +++ b/src/v2/generated/models/Dropdown.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/DropdownValue.ts b/src/v2/generated/models/DropdownValue.ts index d46cf48..8d0e70a 100644 --- a/src/v2/generated/models/DropdownValue.ts +++ b/src/v2/generated/models/DropdownValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,7 +17,7 @@ export class DropdownValue { /** * The type of value */ - 'type': DropdownValueTypeEnum; + 'type': string; 'data': Dropdown | null; static readonly discriminator: string | undefined = undefined; @@ -28,7 +28,7 @@ export class DropdownValue { { "name": "type", "baseName": "type", - "type": "DropdownValueTypeEnum", + "type": "string", "format": "" }, { @@ -45,8 +45,3 @@ export class DropdownValue { public constructor() { } } - -export enum DropdownValueTypeEnum { - Dropdown = 'dropdown' -} - diff --git a/src/v2/generated/models/DropdownsValue.ts b/src/v2/generated/models/DropdownsValue.ts index 2430f5e..d053373 100644 --- a/src/v2/generated/models/DropdownsValue.ts +++ b/src/v2/generated/models/DropdownsValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,11 +17,11 @@ export class DropdownsValue { /** * The type of value */ - 'type': DropdownsValueTypeEnum; + 'type': string; /** * The value for many dropdown items */ - 'data': Array | null; + 'data': Array; static readonly discriminator: string | undefined = undefined; @@ -31,7 +31,7 @@ export class DropdownsValue { { "name": "type", "baseName": "type", - "type": "DropdownsValueTypeEnum", + "type": "string", "format": "" }, { @@ -48,8 +48,3 @@ export class DropdownsValue { public constructor() { } } - -export enum DropdownsValueTypeEnum { - DropdownMulti = 'dropdown-multi' -} - diff --git a/src/v2/generated/models/Email.ts b/src/v2/generated/models/Email.ts index 3a711b3..37653e1 100644 --- a/src/v2/generated/models/Email.ts +++ b/src/v2/generated/models/Email.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,7 +17,7 @@ export class Email { /** * The type of interaction */ - 'type': EmailTypeEnum; + 'type': string; /** * The email\'s unique identifier */ @@ -30,7 +30,7 @@ export class Email { * The time the email was sent */ 'sentAt': Date; - 'from': Attendee; + '_from': Attendee; /** * The recipients of the email */ @@ -48,7 +48,7 @@ export class Email { { "name": "type", "baseName": "type", - "type": "EmailTypeEnum", + "type": "string", "format": "" }, { @@ -70,7 +70,7 @@ export class Email { "format": "date-time" }, { - "name": "from", + "name": "_from", "baseName": "from", "type": "Attendee", "format": "" @@ -95,8 +95,3 @@ export class Email { public constructor() { } } - -export enum EmailTypeEnum { - Email = 'email' -} - diff --git a/src/v2/generated/models/EmptyMessageBodyError.ts b/src/v2/generated/models/EmptyMessageBodyError.ts deleted file mode 100644 index f908260..0000000 --- a/src/v2/generated/models/EmptyMessageBodyError.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. - * - * OpenAPI spec version: 2.0.0 - * Contact: support@affinity.co - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { HttpFile } from '../http/http.ts'; - -export class EmptyMessageBodyError { - /** - * Error code - */ - 'code'?: string | null; - /** - * Error message - */ - 'message'?: string | null; - - static readonly discriminator: string | undefined = undefined; - - static readonly mapping: {[index: string]: string} | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ - { - "name": "code", - "baseName": "code", - "type": "string", - "format": "" - }, - { - "name": "message", - "baseName": "message", - "type": "string", - "format": "" - } ]; - - static getAttributeTypeMap() { - return EmptyMessageBodyError.attributeTypeMap; - } - - public constructor() { - } -} diff --git a/src/v2/generated/models/Errors.ts b/src/v2/generated/models/Errors.ts deleted file mode 100644 index dd05ff9..0000000 --- a/src/v2/generated/models/Errors.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. - * - * OpenAPI spec version: 2.0.0 - * Contact: support@affinity.co - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { HttpFile } from '../http/http.ts'; - -export class Errors { - /** - * Errors - */ - 'errors'?: Array | null; - - static readonly discriminator: string | undefined = undefined; - - static readonly mapping: {[index: string]: string} | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ - { - "name": "errors", - "baseName": "errors", - "type": "Array", - "format": "" - } ]; - - static getAttributeTypeMap() { - return Errors.attributeTypeMap; - } - - public constructor() { - } -} diff --git a/src/v2/generated/models/Field.ts b/src/v2/generated/models/Field.ts index 29ef0d4..7aaff1c 100644 --- a/src/v2/generated/models/Field.ts +++ b/src/v2/generated/models/Field.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/FieldMetadata.ts b/src/v2/generated/models/FieldMetadata.ts index 59e9e23..f81ec0f 100644 --- a/src/v2/generated/models/FieldMetadata.ts +++ b/src/v2/generated/models/FieldMetadata.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/FieldMetadataPaged.ts b/src/v2/generated/models/FieldMetadataPaged.ts index 267ae31..f9186e9 100644 --- a/src/v2/generated/models/FieldMetadataPaged.ts +++ b/src/v2/generated/models/FieldMetadataPaged.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/FieldValue.ts b/src/v2/generated/models/FieldValue.ts index 3a3a9ca..c0f8035 100644 --- a/src/v2/generated/models/FieldValue.ts +++ b/src/v2/generated/models/FieldValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/FloatValue.ts b/src/v2/generated/models/FloatValue.ts index d3be36e..19d53b9 100644 --- a/src/v2/generated/models/FloatValue.ts +++ b/src/v2/generated/models/FloatValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -16,7 +16,7 @@ export class FloatValue { /** * The type of value */ - 'type': FloatValueTypeEnum; + 'type': string; /** * The value for a number */ @@ -30,7 +30,7 @@ export class FloatValue { { "name": "type", "baseName": "type", - "type": "FloatValueTypeEnum", + "type": "string", "format": "" }, { @@ -47,8 +47,3 @@ export class FloatValue { public constructor() { } } - -export enum FloatValueTypeEnum { - Number = 'number' -} - diff --git a/src/v2/generated/models/FloatsValue.ts b/src/v2/generated/models/FloatsValue.ts index 8c2d9c7..a5d8850 100644 --- a/src/v2/generated/models/FloatsValue.ts +++ b/src/v2/generated/models/FloatsValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -16,11 +16,11 @@ export class FloatsValue { /** * The type of value */ - 'type': FloatsValueTypeEnum; + 'type': string; /** * The value for many numbers */ - 'data': Array | null; + 'data': Array; static readonly discriminator: string | undefined = undefined; @@ -30,7 +30,7 @@ export class FloatsValue { { "name": "type", "baseName": "type", - "type": "FloatsValueTypeEnum", + "type": "string", "format": "" }, { @@ -47,8 +47,3 @@ export class FloatsValue { public constructor() { } } - -export enum FloatsValueTypeEnum { - NumberMulti = 'number-multi' -} - diff --git a/src/v2/generated/models/FormulaNumber.ts b/src/v2/generated/models/FormulaNumber.ts index 02730b0..b8cda0f 100644 --- a/src/v2/generated/models/FormulaNumber.ts +++ b/src/v2/generated/models/FormulaNumber.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/FormulaValue.ts b/src/v2/generated/models/FormulaValue.ts index 02a114b..21dbf2d 100644 --- a/src/v2/generated/models/FormulaValue.ts +++ b/src/v2/generated/models/FormulaValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,7 +17,7 @@ export class FormulaValue { /** * The type of value */ - 'type': FormulaValueTypeEnum; + 'type': string; 'data': FormulaNumber | null; static readonly discriminator: string | undefined = undefined; @@ -28,7 +28,7 @@ export class FormulaValue { { "name": "type", "baseName": "type", - "type": "FormulaValueTypeEnum", + "type": "string", "format": "" }, { @@ -45,8 +45,3 @@ export class FormulaValue { public constructor() { } } - -export enum FormulaValueTypeEnum { - FormulaNumber = 'formula-number' -} - diff --git a/src/v2/generated/models/GenericError.ts b/src/v2/generated/models/GenericError.ts deleted file mode 100644 index a97a70a..0000000 --- a/src/v2/generated/models/GenericError.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. - * - * OpenAPI spec version: 2.0.0 - * Contact: support@affinity.co - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { HttpFile } from '../http/http.ts'; - -export class GenericError { - /** - * Error code - */ - 'code'?: string | null; - /** - * Error message - */ - 'message'?: string | null; - - static readonly discriminator: string | undefined = undefined; - - static readonly mapping: {[index: string]: string} | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ - { - "name": "code", - "baseName": "code", - "type": "string", - "format": "" - }, - { - "name": "message", - "baseName": "message", - "type": "string", - "format": "" - } ]; - - static getAttributeTypeMap() { - return GenericError.attributeTypeMap; - } - - public constructor() { - } -} diff --git a/src/v2/generated/models/Grant.ts b/src/v2/generated/models/Grant.ts index 2287cf5..db2a333 100644 --- a/src/v2/generated/models/Grant.ts +++ b/src/v2/generated/models/Grant.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -16,7 +16,7 @@ export class Grant { /** * The type of grant used to authenticate */ - 'type': GrantTypeEnum; + 'type': string; /** * The scopes available to the current grant */ @@ -34,7 +34,7 @@ export class Grant { { "name": "type", "baseName": "type", - "type": "GrantTypeEnum", + "type": "string", "format": "" }, { @@ -57,8 +57,3 @@ export class Grant { public constructor() { } } - -export enum GrantTypeEnum { - ApiKey = 'api-key' -} - diff --git a/src/v2/generated/models/Interaction.ts b/src/v2/generated/models/Interaction.ts index c811b26..3c7ad7d 100644 --- a/src/v2/generated/models/Interaction.ts +++ b/src/v2/generated/models/Interaction.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/InteractionValue.ts b/src/v2/generated/models/InteractionValue.ts index 80a5cda..39c8064 100644 --- a/src/v2/generated/models/InteractionValue.ts +++ b/src/v2/generated/models/InteractionValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,7 +17,7 @@ export class InteractionValue { /** * The type of value */ - 'type': InteractionValueTypeEnum; + 'type': string; 'data': Interaction | null; static readonly discriminator: string | undefined = undefined; @@ -28,7 +28,7 @@ export class InteractionValue { { "name": "type", "baseName": "type", - "type": "InteractionValueTypeEnum", + "type": "string", "format": "" }, { @@ -45,8 +45,3 @@ export class InteractionValue { public constructor() { } } - -export enum InteractionValueTypeEnum { - Interaction = 'interaction' -} - diff --git a/src/v2/generated/models/InvalidAcceptHeaderError.ts b/src/v2/generated/models/InvalidAcceptHeaderError.ts deleted file mode 100644 index 508dde2..0000000 --- a/src/v2/generated/models/InvalidAcceptHeaderError.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. - * - * OpenAPI spec version: 2.0.0 - * Contact: support@affinity.co - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { HttpFile } from '../http/http.ts'; - -export class InvalidAcceptHeaderError { - /** - * Error code - */ - 'code'?: string | null; - /** - * Error message - */ - 'message'?: string | null; - - static readonly discriminator: string | undefined = undefined; - - static readonly mapping: {[index: string]: string} | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ - { - "name": "code", - "baseName": "code", - "type": "string", - "format": "" - }, - { - "name": "message", - "baseName": "message", - "type": "string", - "format": "" - } ]; - - static getAttributeTypeMap() { - return InvalidAcceptHeaderError.attributeTypeMap; - } - - public constructor() { - } -} diff --git a/src/v2/generated/models/InvalidMessageBodyError.ts b/src/v2/generated/models/InvalidMessageBodyError.ts deleted file mode 100644 index c4337a2..0000000 --- a/src/v2/generated/models/InvalidMessageBodyError.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. - * - * OpenAPI spec version: 2.0.0 - * Contact: support@affinity.co - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { HttpFile } from '../http/http.ts'; - -export class InvalidMessageBodyError { - /** - * Error code - */ - 'code'?: string | null; - /** - * Error message - */ - 'message'?: string | null; - - static readonly discriminator: string | undefined = undefined; - - static readonly mapping: {[index: string]: string} | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ - { - "name": "code", - "baseName": "code", - "type": "string", - "format": "" - }, - { - "name": "message", - "baseName": "message", - "type": "string", - "format": "" - } ]; - - static getAttributeTypeMap() { - return InvalidMessageBodyError.attributeTypeMap; - } - - public constructor() { - } -} diff --git a/src/v2/generated/models/InvalidVersionHeaderError.ts b/src/v2/generated/models/InvalidVersionHeaderError.ts deleted file mode 100644 index c0ba9d4..0000000 --- a/src/v2/generated/models/InvalidVersionHeaderError.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. - * - * OpenAPI spec version: 2.0.0 - * Contact: support@affinity.co - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { HttpFile } from '../http/http.ts'; - -export class InvalidVersionHeaderError { - /** - * Error code - */ - 'code'?: string | null; - /** - * Error message - */ - 'message'?: string | null; - - static readonly discriminator: string | undefined = undefined; - - static readonly mapping: {[index: string]: string} | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ - { - "name": "code", - "baseName": "code", - "type": "string", - "format": "" - }, - { - "name": "message", - "baseName": "message", - "type": "string", - "format": "" - } ]; - - static getAttributeTypeMap() { - return InvalidVersionHeaderError.attributeTypeMap; - } - - public constructor() { - } -} diff --git a/src/v2/generated/models/List.ts b/src/v2/generated/models/List.ts index 6cf2460..8702f4f 100644 --- a/src/v2/generated/models/List.ts +++ b/src/v2/generated/models/List.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/ListEntry.ts b/src/v2/generated/models/ListEntry.ts index 188de9f..92ada12 100644 --- a/src/v2/generated/models/ListEntry.ts +++ b/src/v2/generated/models/ListEntry.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/ListEntryPaged.ts b/src/v2/generated/models/ListEntryPaged.ts index 8c5aa84..8b3b6cf 100644 --- a/src/v2/generated/models/ListEntryPaged.ts +++ b/src/v2/generated/models/ListEntryPaged.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/ListEntryWithEntity.ts b/src/v2/generated/models/ListEntryWithEntity.ts index ab86530..35f5520 100644 --- a/src/v2/generated/models/ListEntryWithEntity.ts +++ b/src/v2/generated/models/ListEntryWithEntity.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/ListEntryWithEntityPaged.ts b/src/v2/generated/models/ListEntryWithEntityPaged.ts index 047d58c..c6afb1f 100644 --- a/src/v2/generated/models/ListEntryWithEntityPaged.ts +++ b/src/v2/generated/models/ListEntryWithEntityPaged.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -21,7 +21,7 @@ export class ListEntryWithEntityPaged { /** * A page of ListEntryWithEntity results */ - 'data': Array | null; + 'data': Array; 'pagination': Pagination; static readonly discriminator: string | undefined = undefined; diff --git a/src/v2/generated/models/ListPaged.ts b/src/v2/generated/models/ListPaged.ts index 28e21cb..87d880a 100644 --- a/src/v2/generated/models/ListPaged.ts +++ b/src/v2/generated/models/ListPaged.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/ListWithType.ts b/src/v2/generated/models/ListWithType.ts index 9a0b1ac..723ee5f 100644 --- a/src/v2/generated/models/ListWithType.ts +++ b/src/v2/generated/models/ListWithType.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/ListWithTypePaged.ts b/src/v2/generated/models/ListWithTypePaged.ts index 25d917a..e3a9c3d 100644 --- a/src/v2/generated/models/ListWithTypePaged.ts +++ b/src/v2/generated/models/ListWithTypePaged.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/Location.ts b/src/v2/generated/models/Location.ts index 8a33a3d..1991295 100644 --- a/src/v2/generated/models/Location.ts +++ b/src/v2/generated/models/Location.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/LocationValue.ts b/src/v2/generated/models/LocationValue.ts index 1b2276c..e5a9a37 100644 --- a/src/v2/generated/models/LocationValue.ts +++ b/src/v2/generated/models/LocationValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,7 +17,7 @@ export class LocationValue { /** * The type of value */ - 'type': LocationValueTypeEnum; + 'type': string; 'data': Location | null; static readonly discriminator: string | undefined = undefined; @@ -28,7 +28,7 @@ export class LocationValue { { "name": "type", "baseName": "type", - "type": "LocationValueTypeEnum", + "type": "string", "format": "" }, { @@ -45,8 +45,3 @@ export class LocationValue { public constructor() { } } - -export enum LocationValueTypeEnum { - Location = 'location' -} - diff --git a/src/v2/generated/models/LocationsValue.ts b/src/v2/generated/models/LocationsValue.ts index b1f9515..a0cbff1 100644 --- a/src/v2/generated/models/LocationsValue.ts +++ b/src/v2/generated/models/LocationsValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,11 +17,11 @@ export class LocationsValue { /** * The type of value */ - 'type': LocationsValueTypeEnum; + 'type': string; /** * The values for many locations */ - 'data': Array | null; + 'data': Array; static readonly discriminator: string | undefined = undefined; @@ -31,7 +31,7 @@ export class LocationsValue { { "name": "type", "baseName": "type", - "type": "LocationsValueTypeEnum", + "type": "string", "format": "" }, { @@ -48,8 +48,3 @@ export class LocationsValue { public constructor() { } } - -export enum LocationsValueTypeEnum { - LocationMulti = 'location-multi' -} - diff --git a/src/v2/generated/models/Meeting.ts b/src/v2/generated/models/Meeting.ts index 5359c8a..b52d2e9 100644 --- a/src/v2/generated/models/Meeting.ts +++ b/src/v2/generated/models/Meeting.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,7 +17,7 @@ export class Meeting { /** * The type of interaction */ - 'type': MeetingTypeEnum; + 'type': string; /** * The meeting\'s unique identifier */ @@ -51,7 +51,7 @@ export class Meeting { { "name": "type", "baseName": "type", - "type": "MeetingTypeEnum", + "type": "string", "format": "" }, { @@ -98,8 +98,3 @@ export class Meeting { public constructor() { } } - -export enum MeetingTypeEnum { - Meeting = 'meeting' -} - diff --git a/src/v2/generated/models/MethodNotAllowedError.ts b/src/v2/generated/models/MethodNotAllowedError.ts deleted file mode 100644 index 4dd3592..0000000 --- a/src/v2/generated/models/MethodNotAllowedError.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. - * - * OpenAPI spec version: 2.0.0 - * Contact: support@affinity.co - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { HttpFile } from '../http/http.ts'; - -export class MethodNotAllowedError { - /** - * Error code - */ - 'code'?: string | null; - /** - * Error message - */ - 'message'?: string | null; - - static readonly discriminator: string | undefined = undefined; - - static readonly mapping: {[index: string]: string} | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ - { - "name": "code", - "baseName": "code", - "type": "string", - "format": "" - }, - { - "name": "message", - "baseName": "message", - "type": "string", - "format": "" - } ]; - - static getAttributeTypeMap() { - return MethodNotAllowedError.attributeTypeMap; - } - - public constructor() { - } -} diff --git a/src/v2/generated/models/ModelError.ts b/src/v2/generated/models/ModelError.ts deleted file mode 100644 index 592803c..0000000 --- a/src/v2/generated/models/ModelError.ts +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. - * - * OpenAPI spec version: 2.0.0 - * Contact: support@affinity.co - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { AuthenticationError } from '../models/AuthenticationError.ts'; -import { AuthorizationError } from '../models/AuthorizationError.ts'; -import { ConflictError } from '../models/ConflictError.ts'; -import { EmptyMessageBodyError } from '../models/EmptyMessageBodyError.ts'; -import { GenericError } from '../models/GenericError.ts'; -import { InvalidAcceptHeaderError } from '../models/InvalidAcceptHeaderError.ts'; -import { InvalidMessageBodyError } from '../models/InvalidMessageBodyError.ts'; -import { InvalidVersionHeaderError } from '../models/InvalidVersionHeaderError.ts'; -import { MethodNotAllowedError } from '../models/MethodNotAllowedError.ts'; -import { NotFoundError } from '../models/NotFoundError.ts'; -import { RateLimitError } from '../models/RateLimitError.ts'; -import { ServerError } from '../models/ServerError.ts'; -import { TooManyMultipartFilesError } from '../models/TooManyMultipartFilesError.ts'; -import { ValidationError } from '../models/ValidationError.ts'; -import { HttpFile } from '../http/http.ts'; - -/** - * @type ModelError - * Type - * @export - */ -export type ModelError = AuthenticationError | AuthorizationError | ConflictError | EmptyMessageBodyError | GenericError | InvalidAcceptHeaderError | InvalidMessageBodyError | InvalidVersionHeaderError | MethodNotAllowedError | NotFoundError | RateLimitError | ServerError | TooManyMultipartFilesError | ValidationError; - -/** -* @type ModelErrorClass -* @export -*/ -export class ModelErrorClass { - static readonly discriminator: string | undefined = "code"; - - static readonly mapping: {[index: string]: string} | undefined = { - "authentication": "AuthenticationError", - "authorization": "AuthorizationError", - "conflict": "ConflictError", - "empty-message-body": "EmptyMessageBodyError", - "error": "GenericError", - "invalid-accept-header": "InvalidAcceptHeaderError", - "invalid-message-body": "InvalidMessageBodyError", - "invalid-version-header": "InvalidVersionHeaderError", - "method-not-allowed": "MethodNotAllowedError", - "not-found": "NotFoundError", - "rate-limit": "RateLimitError", - "server": "ServerError", - "too-many-multipart-files": "TooManyMultipartFilesError", - "validation": "ValidationError", - }; -} - - - - - - - - - - - - - diff --git a/src/v2/generated/models/NotFoundError.ts b/src/v2/generated/models/NotFoundError.ts index 25c81ef..72f82e1 100644 --- a/src/v2/generated/models/NotFoundError.ts +++ b/src/v2/generated/models/NotFoundError.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -16,11 +16,11 @@ export class NotFoundError { /** * Error code */ - 'code'?: string | null; + 'code': string; /** * Error message */ - 'message'?: string | null; + 'message': string; static readonly discriminator: string | undefined = undefined; diff --git a/src/v2/generated/models/NotFoundErrors.ts b/src/v2/generated/models/NotFoundErrors.ts index 3b995191..8aba256 100644 --- a/src/v2/generated/models/NotFoundErrors.ts +++ b/src/v2/generated/models/NotFoundErrors.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -20,7 +20,7 @@ export class NotFoundErrors { /** * NotFoundError errors */ - 'errors'?: Array | null; + 'errors': Array; static readonly discriminator: string | undefined = undefined; diff --git a/src/v2/generated/models/ObjectSerializer.ts b/src/v2/generated/models/ObjectSerializer.ts index e16e566..194a6eb 100644 --- a/src/v2/generated/models/ObjectSerializer.ts +++ b/src/v2/generated/models/ObjectSerializer.ts @@ -10,14 +10,11 @@ export * from '../models/CompanyData.ts'; export * from '../models/CompanyListEntry.ts'; export * from '../models/CompanyPaged.ts'; export * from '../models/CompanyValue.ts'; -export * from '../models/ConflictError.ts'; export * from '../models/DateValue.ts'; export * from '../models/Dropdown.ts'; export * from '../models/DropdownValue.ts'; export * from '../models/DropdownsValue.ts'; export * from '../models/Email.ts'; -export * from '../models/EmptyMessageBodyError.ts'; -export * from '../models/Errors.ts'; export * from '../models/Field.ts'; export * from '../models/FieldMetadata.ts'; export * from '../models/FieldMetadataPaged.ts'; @@ -26,13 +23,9 @@ export * from '../models/FloatValue.ts'; export * from '../models/FloatsValue.ts'; export * from '../models/FormulaNumber.ts'; export * from '../models/FormulaValue.ts'; -export * from '../models/GenericError.ts'; export * from '../models/Grant.ts'; export * from '../models/Interaction.ts'; export * from '../models/InteractionValue.ts'; -export * from '../models/InvalidAcceptHeaderError.ts'; -export * from '../models/InvalidMessageBodyError.ts'; -export * from '../models/InvalidVersionHeaderError.ts'; export * from '../models/List.ts'; export * from '../models/ListEntry.ts'; export * from '../models/ListEntryPaged.ts'; @@ -45,8 +38,6 @@ export * from '../models/Location.ts'; export * from '../models/LocationValue.ts'; export * from '../models/LocationsValue.ts'; export * from '../models/Meeting.ts'; -export * from '../models/MethodNotAllowedError.ts'; -export * from '../models/ModelError.ts'; export * from '../models/NotFoundError.ts'; export * from '../models/NotFoundErrors.ts'; export * from '../models/Opportunity.ts'; @@ -63,14 +54,11 @@ export * from '../models/PersonsValue.ts'; export * from '../models/PhoneCall.ts'; export * from '../models/RankedDropdown.ts'; export * from '../models/RankedDropdownValue.ts'; -export * from '../models/RateLimitError.ts'; export * from '../models/SavedView.ts'; export * from '../models/SavedViewPaged.ts'; -export * from '../models/ServerError.ts'; export * from '../models/Tenant.ts'; export * from '../models/TextValue.ts'; export * from '../models/TextsValue.ts'; -export * from '../models/TooManyMultipartFilesError.ts'; export * from '../models/User.ts'; export * from '../models/ValidationError.ts'; export * from '../models/ValidationErrors.ts'; @@ -81,36 +69,29 @@ import { AuthenticationError } from '../models/AuthenticationError.ts'; import { AuthenticationErrors } from '../models/AuthenticationErrors.ts'; import { AuthorizationError } from '../models/AuthorizationError.ts'; import { AuthorizationErrors } from '../models/AuthorizationErrors.ts'; -import { ChatMessage, ChatMessageTypeEnum , ChatMessageDirectionEnum } from '../models/ChatMessage.ts'; -import { CompaniesValue, CompaniesValueTypeEnum } from '../models/CompaniesValue.ts'; +import { ChatMessage , ChatMessageDirectionEnum } from '../models/ChatMessage.ts'; +import { CompaniesValue } from '../models/CompaniesValue.ts'; import { Company } from '../models/Company.ts'; import { CompanyData } from '../models/CompanyData.ts'; -import { CompanyListEntry , CompanyListEntryTypeEnum } from '../models/CompanyListEntry.ts'; +import { CompanyListEntry } from '../models/CompanyListEntry.ts'; import { CompanyPaged } from '../models/CompanyPaged.ts'; -import { CompanyValue, CompanyValueTypeEnum } from '../models/CompanyValue.ts'; -import { ConflictError } from '../models/ConflictError.ts'; -import { DateValue, DateValueTypeEnum } from '../models/DateValue.ts'; +import { CompanyValue } from '../models/CompanyValue.ts'; +import { DateValue } from '../models/DateValue.ts'; import { Dropdown } from '../models/Dropdown.ts'; -import { DropdownValue, DropdownValueTypeEnum } from '../models/DropdownValue.ts'; -import { DropdownsValue, DropdownsValueTypeEnum } from '../models/DropdownsValue.ts'; -import { Email, EmailTypeEnum } from '../models/Email.ts'; -import { EmptyMessageBodyError } from '../models/EmptyMessageBodyError.ts'; -import { Errors } from '../models/Errors.ts'; +import { DropdownValue } from '../models/DropdownValue.ts'; +import { DropdownsValue } from '../models/DropdownsValue.ts'; +import { Email } from '../models/Email.ts'; import { Field , FieldTypeEnum , FieldEnrichmentSourceEnum } from '../models/Field.ts'; import { FieldMetadata , FieldMetadataTypeEnum , FieldMetadataEnrichmentSourceEnum , FieldMetadataValueTypeEnum } from '../models/FieldMetadata.ts'; import { FieldMetadataPaged } from '../models/FieldMetadataPaged.ts'; import { FieldValueClass } from '../models/FieldValue.ts'; -import { FloatValue, FloatValueTypeEnum } from '../models/FloatValue.ts'; -import { FloatsValue, FloatsValueTypeEnum } from '../models/FloatsValue.ts'; +import { FloatValue } from '../models/FloatValue.ts'; +import { FloatsValue } from '../models/FloatsValue.ts'; import { FormulaNumber } from '../models/FormulaNumber.ts'; -import { FormulaValue, FormulaValueTypeEnum } from '../models/FormulaValue.ts'; -import { GenericError } from '../models/GenericError.ts'; -import { Grant, GrantTypeEnum } from '../models/Grant.ts'; +import { FormulaValue } from '../models/FormulaValue.ts'; +import { Grant } from '../models/Grant.ts'; import { InteractionClass } from '../models/Interaction.ts'; -import { InteractionValue, InteractionValueTypeEnum } from '../models/InteractionValue.ts'; -import { InvalidAcceptHeaderError } from '../models/InvalidAcceptHeaderError.ts'; -import { InvalidMessageBodyError } from '../models/InvalidMessageBodyError.ts'; -import { InvalidVersionHeaderError } from '../models/InvalidVersionHeaderError.ts'; +import { InteractionValue } from '../models/InteractionValue.ts'; import { List } from '../models/List.ts'; import { ListEntry } from '../models/ListEntry.ts'; import { ListEntryPaged } from '../models/ListEntryPaged.ts'; @@ -120,35 +101,30 @@ import { ListPaged } from '../models/ListPaged.ts'; import { ListWithType , ListWithTypeTypeEnum } from '../models/ListWithType.ts'; import { ListWithTypePaged } from '../models/ListWithTypePaged.ts'; import { Location } from '../models/Location.ts'; -import { LocationValue, LocationValueTypeEnum } from '../models/LocationValue.ts'; -import { LocationsValue, LocationsValueTypeEnum } from '../models/LocationsValue.ts'; -import { Meeting, MeetingTypeEnum } from '../models/Meeting.ts'; -import { MethodNotAllowedError } from '../models/MethodNotAllowedError.ts'; -import { ModelErrorClass } from '../models/ModelError.ts'; +import { LocationValue } from '../models/LocationValue.ts'; +import { LocationsValue } from '../models/LocationsValue.ts'; +import { Meeting } from '../models/Meeting.ts'; import { NotFoundError } from '../models/NotFoundError.ts'; import { NotFoundErrors } from '../models/NotFoundErrors.ts'; import { Opportunity } from '../models/Opportunity.ts'; -import { OpportunityListEntry , OpportunityListEntryTypeEnum } from '../models/OpportunityListEntry.ts'; +import { OpportunityListEntry } from '../models/OpportunityListEntry.ts'; import { OpportunityPaged } from '../models/OpportunityPaged.ts'; import { OpportunityWithFields } from '../models/OpportunityWithFields.ts'; import { Pagination } from '../models/Pagination.ts'; import { Person , PersonTypeEnum } from '../models/Person.ts'; import { PersonData , PersonDataTypeEnum } from '../models/PersonData.ts'; -import { PersonListEntry , PersonListEntryTypeEnum } from '../models/PersonListEntry.ts'; +import { PersonListEntry } from '../models/PersonListEntry.ts'; import { PersonPaged } from '../models/PersonPaged.ts'; -import { PersonValue, PersonValueTypeEnum } from '../models/PersonValue.ts'; -import { PersonsValue, PersonsValueTypeEnum } from '../models/PersonsValue.ts'; -import { PhoneCall, PhoneCallTypeEnum } from '../models/PhoneCall.ts'; +import { PersonValue } from '../models/PersonValue.ts'; +import { PersonsValue } from '../models/PersonsValue.ts'; +import { PhoneCall } from '../models/PhoneCall.ts'; import { RankedDropdown } from '../models/RankedDropdown.ts'; -import { RankedDropdownValue, RankedDropdownValueTypeEnum } from '../models/RankedDropdownValue.ts'; -import { RateLimitError } from '../models/RateLimitError.ts'; +import { RankedDropdownValue } from '../models/RankedDropdownValue.ts'; import { SavedView , SavedViewTypeEnum } from '../models/SavedView.ts'; import { SavedViewPaged } from '../models/SavedViewPaged.ts'; -import { ServerError } from '../models/ServerError.ts'; import { Tenant } from '../models/Tenant.ts'; import { TextValue, TextValueTypeEnum } from '../models/TextValue.ts'; -import { TextsValue, TextsValueTypeEnum } from '../models/TextsValue.ts'; -import { TooManyMultipartFilesError } from '../models/TooManyMultipartFilesError.ts'; +import { TextsValue } from '../models/TextsValue.ts'; import { User } from '../models/User.ts'; import { ValidationError } from '../models/ValidationError.ts'; import { ValidationErrors } from '../models/ValidationErrors.ts'; @@ -167,44 +143,21 @@ let primitives = [ ]; let enumsMap: Set = new Set([ - "ChatMessageTypeEnum", "ChatMessageDirectionEnum", - "CompaniesValueTypeEnum", - "CompanyListEntryTypeEnum", - "CompanyValueTypeEnum", - "DateValueTypeEnum", - "DropdownValueTypeEnum", - "DropdownsValueTypeEnum", - "EmailTypeEnum", "FieldTypeEnum", "FieldEnrichmentSourceEnum", "FieldMetadataTypeEnum", "FieldMetadataEnrichmentSourceEnum", "FieldMetadataValueTypeEnum", "FieldValueTypeEnum", - "FloatValueTypeEnum", - "FloatsValueTypeEnum", - "FormulaValueTypeEnum", - "GrantTypeEnum", "InteractionTypeEnum", "InteractionDirectionEnum", - "InteractionValueTypeEnum", "ListEntryWithEntityTypeEnum", "ListWithTypeTypeEnum", - "LocationValueTypeEnum", - "LocationsValueTypeEnum", - "MeetingTypeEnum", - "OpportunityListEntryTypeEnum", "PersonTypeEnum", "PersonDataTypeEnum", - "PersonListEntryTypeEnum", - "PersonValueTypeEnum", - "PersonsValueTypeEnum", - "PhoneCallTypeEnum", - "RankedDropdownValueTypeEnum", "SavedViewTypeEnum", "TextValueTypeEnum", - "TextsValueTypeEnum", ]); let typeMap: {[index: string]: any} = { @@ -220,14 +173,11 @@ let typeMap: {[index: string]: any} = { "CompanyListEntry": CompanyListEntry, "CompanyPaged": CompanyPaged, "CompanyValue": CompanyValue, - "ConflictError": ConflictError, "DateValue": DateValue, "Dropdown": Dropdown, "DropdownValue": DropdownValue, "DropdownsValue": DropdownsValue, "Email": Email, - "EmptyMessageBodyError": EmptyMessageBodyError, - "Errors": Errors, "Field": Field, "FieldMetadata": FieldMetadata, "FieldMetadataPaged": FieldMetadataPaged, @@ -236,13 +186,9 @@ let typeMap: {[index: string]: any} = { "FloatsValue": FloatsValue, "FormulaNumber": FormulaNumber, "FormulaValue": FormulaValue, - "GenericError": GenericError, "Grant": Grant, "Interaction": InteractionClass, "InteractionValue": InteractionValue, - "InvalidAcceptHeaderError": InvalidAcceptHeaderError, - "InvalidMessageBodyError": InvalidMessageBodyError, - "InvalidVersionHeaderError": InvalidVersionHeaderError, "List": List, "ListEntry": ListEntry, "ListEntryPaged": ListEntryPaged, @@ -255,8 +201,6 @@ let typeMap: {[index: string]: any} = { "LocationValue": LocationValue, "LocationsValue": LocationsValue, "Meeting": Meeting, - "MethodNotAllowedError": MethodNotAllowedError, - "ModelError": ModelErrorClass, "NotFoundError": NotFoundError, "NotFoundErrors": NotFoundErrors, "Opportunity": Opportunity, @@ -273,14 +217,11 @@ let typeMap: {[index: string]: any} = { "PhoneCall": PhoneCall, "RankedDropdown": RankedDropdown, "RankedDropdownValue": RankedDropdownValue, - "RateLimitError": RateLimitError, "SavedView": SavedView, "SavedViewPaged": SavedViewPaged, - "ServerError": ServerError, "Tenant": Tenant, "TextValue": TextValue, "TextsValue": TextsValue, - "TooManyMultipartFilesError": TooManyMultipartFilesError, "User": User, "ValidationError": ValidationError, "ValidationErrors": ValidationErrors, diff --git a/src/v2/generated/models/Opportunity.ts b/src/v2/generated/models/Opportunity.ts index cad6782..8ff75ff 100644 --- a/src/v2/generated/models/Opportunity.ts +++ b/src/v2/generated/models/Opportunity.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/OpportunityListEntry.ts b/src/v2/generated/models/OpportunityListEntry.ts index 14f01d1..ef356d0 100644 --- a/src/v2/generated/models/OpportunityListEntry.ts +++ b/src/v2/generated/models/OpportunityListEntry.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -21,7 +21,7 @@ export class OpportunityListEntry { /** * The entity type for this list entry */ - 'type': OpportunityListEntryTypeEnum; + 'type': string; /** * The date that the list entry was created */ @@ -46,7 +46,7 @@ export class OpportunityListEntry { { "name": "type", "baseName": "type", - "type": "OpportunityListEntryTypeEnum", + "type": "string", "format": "" }, { @@ -75,8 +75,3 @@ export class OpportunityListEntry { public constructor() { } } - -export enum OpportunityListEntryTypeEnum { - Opportunity = 'opportunity' -} - diff --git a/src/v2/generated/models/OpportunityPaged.ts b/src/v2/generated/models/OpportunityPaged.ts index 58e0cc3..38452d3 100644 --- a/src/v2/generated/models/OpportunityPaged.ts +++ b/src/v2/generated/models/OpportunityPaged.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/OpportunityWithFields.ts b/src/v2/generated/models/OpportunityWithFields.ts index 31d8abc..36babc0 100644 --- a/src/v2/generated/models/OpportunityWithFields.ts +++ b/src/v2/generated/models/OpportunityWithFields.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/Pagination.ts b/src/v2/generated/models/Pagination.ts index 0f63a82..a201090 100644 --- a/src/v2/generated/models/Pagination.ts +++ b/src/v2/generated/models/Pagination.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/Person.ts b/src/v2/generated/models/Person.ts index 587cf82..bbe8c41 100644 --- a/src/v2/generated/models/Person.ts +++ b/src/v2/generated/models/Person.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/PersonData.ts b/src/v2/generated/models/PersonData.ts index 81f8c26..a9d3552 100644 --- a/src/v2/generated/models/PersonData.ts +++ b/src/v2/generated/models/PersonData.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/PersonListEntry.ts b/src/v2/generated/models/PersonListEntry.ts index f9281e3..52b033f 100644 --- a/src/v2/generated/models/PersonListEntry.ts +++ b/src/v2/generated/models/PersonListEntry.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -21,7 +21,7 @@ export class PersonListEntry { /** * The entity type for this list entry */ - 'type': PersonListEntryTypeEnum; + 'type': string; /** * The date that the list entry was created */ @@ -46,7 +46,7 @@ export class PersonListEntry { { "name": "type", "baseName": "type", - "type": "PersonListEntryTypeEnum", + "type": "string", "format": "" }, { @@ -75,8 +75,3 @@ export class PersonListEntry { public constructor() { } } - -export enum PersonListEntryTypeEnum { - Person = 'person' -} - diff --git a/src/v2/generated/models/PersonPaged.ts b/src/v2/generated/models/PersonPaged.ts index 42aadc3..0c8b13f 100644 --- a/src/v2/generated/models/PersonPaged.ts +++ b/src/v2/generated/models/PersonPaged.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/PersonValue.ts b/src/v2/generated/models/PersonValue.ts index cefd953..a1d2a54 100644 --- a/src/v2/generated/models/PersonValue.ts +++ b/src/v2/generated/models/PersonValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,7 +17,7 @@ export class PersonValue { /** * The type of value */ - 'type': PersonValueTypeEnum; + 'type': string; 'data': PersonData | null; static readonly discriminator: string | undefined = undefined; @@ -28,7 +28,7 @@ export class PersonValue { { "name": "type", "baseName": "type", - "type": "PersonValueTypeEnum", + "type": "string", "format": "" }, { @@ -45,8 +45,3 @@ export class PersonValue { public constructor() { } } - -export enum PersonValueTypeEnum { - Person = 'person' -} - diff --git a/src/v2/generated/models/PersonsValue.ts b/src/v2/generated/models/PersonsValue.ts index efb40a7..71ef10d 100644 --- a/src/v2/generated/models/PersonsValue.ts +++ b/src/v2/generated/models/PersonsValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,11 +17,11 @@ export class PersonsValue { /** * The type of value */ - 'type': PersonsValueTypeEnum; + 'type': string; /** * The values for many persons */ - 'data': Array | null; + 'data': Array; static readonly discriminator: string | undefined = undefined; @@ -31,7 +31,7 @@ export class PersonsValue { { "name": "type", "baseName": "type", - "type": "PersonsValueTypeEnum", + "type": "string", "format": "" }, { @@ -48,8 +48,3 @@ export class PersonsValue { public constructor() { } } - -export enum PersonsValueTypeEnum { - PersonMulti = 'person-multi' -} - diff --git a/src/v2/generated/models/PhoneCall.ts b/src/v2/generated/models/PhoneCall.ts index e405470..8d4a492 100644 --- a/src/v2/generated/models/PhoneCall.ts +++ b/src/v2/generated/models/PhoneCall.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,7 +17,7 @@ export class PhoneCall { /** * The type of interaction */ - 'type': PhoneCallTypeEnum; + 'type': string; /** * The phon_call\'s unique identifier */ @@ -39,7 +39,7 @@ export class PhoneCall { { "name": "type", "baseName": "type", - "type": "PhoneCallTypeEnum", + "type": "string", "format": "" }, { @@ -68,8 +68,3 @@ export class PhoneCall { public constructor() { } } - -export enum PhoneCallTypeEnum { - Call = 'call' -} - diff --git a/src/v2/generated/models/RankedDropdown.ts b/src/v2/generated/models/RankedDropdown.ts index 8f3161e..601e5ca 100644 --- a/src/v2/generated/models/RankedDropdown.ts +++ b/src/v2/generated/models/RankedDropdown.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/RankedDropdownValue.ts b/src/v2/generated/models/RankedDropdownValue.ts index fd038df..16e7a25 100644 --- a/src/v2/generated/models/RankedDropdownValue.ts +++ b/src/v2/generated/models/RankedDropdownValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -17,7 +17,7 @@ export class RankedDropdownValue { /** * The type of value */ - 'type': RankedDropdownValueTypeEnum; + 'type': string; 'data': RankedDropdown | null; static readonly discriminator: string | undefined = undefined; @@ -28,7 +28,7 @@ export class RankedDropdownValue { { "name": "type", "baseName": "type", - "type": "RankedDropdownValueTypeEnum", + "type": "string", "format": "" }, { @@ -45,8 +45,3 @@ export class RankedDropdownValue { public constructor() { } } - -export enum RankedDropdownValueTypeEnum { - RankedDropdown = 'ranked-dropdown' -} - diff --git a/src/v2/generated/models/RateLimitError.ts b/src/v2/generated/models/RateLimitError.ts deleted file mode 100644 index 0fcd615..0000000 --- a/src/v2/generated/models/RateLimitError.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. - * - * OpenAPI spec version: 2.0.0 - * Contact: support@affinity.co - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { HttpFile } from '../http/http.ts'; - -export class RateLimitError { - /** - * Error code - */ - 'code'?: string | null; - /** - * Error message - */ - 'message'?: string | null; - - static readonly discriminator: string | undefined = undefined; - - static readonly mapping: {[index: string]: string} | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ - { - "name": "code", - "baseName": "code", - "type": "string", - "format": "" - }, - { - "name": "message", - "baseName": "message", - "type": "string", - "format": "" - } ]; - - static getAttributeTypeMap() { - return RateLimitError.attributeTypeMap; - } - - public constructor() { - } -} diff --git a/src/v2/generated/models/SavedView.ts b/src/v2/generated/models/SavedView.ts index 2c72d98..9893b71 100644 --- a/src/v2/generated/models/SavedView.ts +++ b/src/v2/generated/models/SavedView.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/SavedViewPaged.ts b/src/v2/generated/models/SavedViewPaged.ts index c6dd455..7bb39a6 100644 --- a/src/v2/generated/models/SavedViewPaged.ts +++ b/src/v2/generated/models/SavedViewPaged.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/ServerError.ts b/src/v2/generated/models/ServerError.ts deleted file mode 100644 index bd13722..0000000 --- a/src/v2/generated/models/ServerError.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. - * - * OpenAPI spec version: 2.0.0 - * Contact: support@affinity.co - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { HttpFile } from '../http/http.ts'; - -export class ServerError { - /** - * Error code - */ - 'code'?: string | null; - /** - * Error message - */ - 'message'?: string | null; - - static readonly discriminator: string | undefined = undefined; - - static readonly mapping: {[index: string]: string} | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ - { - "name": "code", - "baseName": "code", - "type": "string", - "format": "" - }, - { - "name": "message", - "baseName": "message", - "type": "string", - "format": "" - } ]; - - static getAttributeTypeMap() { - return ServerError.attributeTypeMap; - } - - public constructor() { - } -} diff --git a/src/v2/generated/models/Tenant.ts b/src/v2/generated/models/Tenant.ts index 51ca803..1f73edd 100644 --- a/src/v2/generated/models/Tenant.ts +++ b/src/v2/generated/models/Tenant.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/TextValue.ts b/src/v2/generated/models/TextValue.ts index 6836e49..9358199 100644 --- a/src/v2/generated/models/TextValue.ts +++ b/src/v2/generated/models/TextValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/TextsValue.ts b/src/v2/generated/models/TextsValue.ts index d409613..efc1649 100644 --- a/src/v2/generated/models/TextsValue.ts +++ b/src/v2/generated/models/TextsValue.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -16,11 +16,11 @@ export class TextsValue { /** * The type of value */ - 'type': TextsValueTypeEnum; + 'type': string; /** * The value for many strings */ - 'data': Array | null; + 'data': Array; static readonly discriminator: string | undefined = undefined; @@ -30,7 +30,7 @@ export class TextsValue { { "name": "type", "baseName": "type", - "type": "TextsValueTypeEnum", + "type": "string", "format": "" }, { @@ -47,8 +47,3 @@ export class TextsValue { public constructor() { } } - -export enum TextsValueTypeEnum { - FilterableTextMulti = 'filterable-text-multi' -} - diff --git a/src/v2/generated/models/TooManyMultipartFilesError.ts b/src/v2/generated/models/TooManyMultipartFilesError.ts deleted file mode 100644 index f9ccd38..0000000 --- a/src/v2/generated/models/TooManyMultipartFilesError.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. - * - * OpenAPI spec version: 2.0.0 - * Contact: support@affinity.co - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { HttpFile } from '../http/http.ts'; - -export class TooManyMultipartFilesError { - /** - * Error code - */ - 'code'?: string | null; - /** - * Error message - */ - 'message'?: string | null; - - static readonly discriminator: string | undefined = undefined; - - static readonly mapping: {[index: string]: string} | undefined = undefined; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ - { - "name": "code", - "baseName": "code", - "type": "string", - "format": "" - }, - { - "name": "message", - "baseName": "message", - "type": "string", - "format": "" - } ]; - - static getAttributeTypeMap() { - return TooManyMultipartFilesError.attributeTypeMap; - } - - public constructor() { - } -} diff --git a/src/v2/generated/models/User.ts b/src/v2/generated/models/User.ts index e5065b6..75c2632 100644 --- a/src/v2/generated/models/User.ts +++ b/src/v2/generated/models/User.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/ValidationError.ts b/src/v2/generated/models/ValidationError.ts index 019d916..4162e56 100644 --- a/src/v2/generated/models/ValidationError.ts +++ b/src/v2/generated/models/ValidationError.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -16,15 +16,15 @@ export class ValidationError { /** * Error code */ - 'code'?: string | null; + 'code': string; /** * Error message */ - 'message'?: string | null; + 'message': string; /** * Param the error refers to */ - 'param'?: string | null; + 'param': string; static readonly discriminator: string | undefined = undefined; diff --git a/src/v2/generated/models/ValidationErrors.ts b/src/v2/generated/models/ValidationErrors.ts index 31ff251..f32f197 100644 --- a/src/v2/generated/models/ValidationErrors.ts +++ b/src/v2/generated/models/ValidationErrors.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co @@ -20,7 +20,7 @@ export class ValidationErrors { /** * ValidationError errors */ - 'errors'?: Array | null; + 'errors': Array; static readonly discriminator: string | undefined = undefined; diff --git a/src/v2/generated/models/WhoAmI.ts b/src/v2/generated/models/WhoAmI.ts index 19cdd18..505af1c 100644 --- a/src/v2/generated/models/WhoAmI.ts +++ b/src/v2/generated/models/WhoAmI.ts @@ -1,6 +1,6 @@ /** * Affinity API v2 - * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. + * # Introduction Welcome to Affinity API v2! This API provides a RESTful interface for building internal apps, automated workflows, and other integrations on top of the core data models in Affinity, and for connecting Affinity to the rest of your tech and data stack. Please note that this new version of the API is not at feature parity with [Affinity API v1](https://api-docs.affinity.co/). We will add to this new version to cover more of v1\'s functionality over time. **This API version is also only available on select Affinity license types.** See [this Help Center article](https://support.affinity.co/hc/en-us/articles/5563700459533-Getting-started-with-the-Affinity-API-FAQs) or contact your Customer Success Manager for more information. # Getting Started All Affinity API endpoints use the base URL `https://api.affinity.co`. All v2 endpoint paths start with `/v2`. Requests must be sent over HTTPS. ## Using These Docs The first few sections of these docs cover general information on the API. Each subsequent section covers a set of API endpoints. Each endpoint is documented with its accepted request parameters, expected response shapes, and a sample request and response. Please note that the shape of a given response can vary depending on what \"type\" of object or data is being returned. When this is the case, the response documentation will include a dropdown that can be used to select the \"type\" for which to display the response shape. ## Authentication Affinity API v2 uses API keys and **bearer authentication** (this is an important difference from Affinity API v1\'s use of basic authentication). To generate an API key, navigate to the Settings page in the Affinity web app. You will need the \"Generate an API key\" role-based permission controlled by your Affinity admin to be able to do this. See [this Help Center article](https://support.affinity.co/hc/en-us/articles/360032633992-How-to-obtain-your-API-Key) for full instructions on API key generation, and [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. Currently, we support one API key per user in your Affinity account. Your API key is able to read data and perform actions in Affinity on your behalf, so keep it safe as you would a password. Provide your API key as your bearer authentication token to start making calls to Affinity API v2. ## Permissions ### Overall requirements You must have the \"Generate an API key\" permission to be able to work with the Affinity API. Most users in most Affinity accounts with API access have this by default — Contact your Affinity admin if you are not able to generate an API key, and see [this article](https://support.affinity.co/hc/en-us/articles/360015976732-Account-Level-Permissions) for more information on role-based permissions in Affinity. ### Resource-level permissions The Affinity API respects sharing permissions that are set in-product. For example, if a given user does not have access to a list, note, or interaction in-product, they will not be able to see or modify it via API. ### Endpoint-level permissions Many API endpoints also require endpoint-specific permissions that map to permissions in-product. These permissions, along with the \"Generate an API key\" permission, are managed by your Affinity admin in the Settings page: | API v2 Endpoint | Required Permission | | ---------------------------------------------------------- | ------------------------------------ | | GET `/v2/companies` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}` | \"Export All Organizations directory\" | | GET `/v2/companies/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/persons` | \"Export All People directory\" | | GET `/v2/persons/{id}` | \"Export All People directory\" | | GET `/v2/persons/{id}/list-entries` | \"Export data from Lists\" | | GET `/v2/opportunities` | \"Export data from Lists\" | | GET `/v2/opportunities/{id}` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/list-entries` | \"Export data from Lists\" | | GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | \"Export data from Lists\" | ## Rate Limits The Affinity API sets a limit on the number of calls that a user can make per minute, and that all the users on an account can make per month. It also sets a reasonable limit on the number of concurrent requests it will support from an account at one time. Requests to **both** Affinity API versions will count toward the one pool of requests allowed for a user or account. Once a per-minute, monthly, or concurrent rate limit is hit, subsequent requests will return an error code of 429. **We highly recommend designing your application to handle 429 errors.** ### Per-Minute Limits (User-Level) To help protect our systems, API requests will be halted at **900 per user, per minute.** We may also lower this limit on a temporary basis to manage API availability. ### Concurrent Request Limits (Account-Level) To protect our systems and manage availability across customers, we set a reasonable limit on concurrent requests at the account level. Customers should not expect to hit this limit unless they are hitting the API with heavy operations from many concurrent threads at once. ### Monthly Plan Tier Limits (Account-Level) The overall number of requests you can make per month will depend on your account\'s plan tier. **This monthly account-level limit resets at the end of each calendar month.** Current rate limits by plan tier are: | Plan Tier | Calls Per Month | | ---------- | --------------- | | Essentials | None | | Scale | 100k | | Advanced | 100k | | Enterprise | Unlimited\\* | \\*Per-Minute and Concurrent Request Limits still apply. ### Rate Limit Headers All API calls will return the following response headers with information about per-minute and monthly limits: | Header | Description | | -------------------------------- | ------------------------------------------------------- | | X-Ratelimit-Limit-User | Number of requests allowed per minute for the user | | X-Ratelimit-Limit-User-Remaining | Number of requests remaining for the user | | X-Ratelimit-Limit-User-Reset | Time in seconds before the limit resets for the user | | X-Ratelimit-Limit-Org | Number of requests allowed per month for the account | | X-Ratelimit-Limit-Org-Remaining | Number of requests remaining for the account | | X-Ratelimit-Limit-Org-Reset | Time in seconds before the limit resets for the account | ## Pagination When an endpoint is expected to return multiple results, we break the results up into pages to make them easier to handle. To cycle forward through multiple pages of data, look for the `nextUrl` property in the `pagination` portion of an API response, and use it for your next request. See endpoint documentation for more information. ## Error Codes Here is a list of the error codes this API will generally return if something goes wrong (see endpoint documentation for endpoint-specific error information): | Error Code | Meaning | | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 400 | Bad Request — See endpoint documentation for more information. | | 401 | Unauthorized — Your API key is invalid. | | 403 | Forbidden — Insufficient rights to a resource. | | 404 | Not Found — Requested resource does not exist. See endpoint documentation for more information. | | 405 | Method Not Allowed — The method being used is not supported for this resource. | | 422 | Unprocessable Entity — Malformed parameters supplied. This can also happen in cases the parameters supplied logically cannot complete the request. In this case, an appropriate error message is delivered. | | 429 | Too Many Requests — You have exceeded the rate limit. | | 500 | Internal Server Error — We had a problem with our server. Try again later. | | 503 | Service Unavailable — This shouldn\'t generally happen. Contact us if you encounter this error. | # Data Model ## The Basics - The three top-level objects in Affinity are **Persons, Companies, and Opportunities**. (Please note: Companies are called Organizations in the Affinity web app.) These have profiles in the Affinity web app and can be added to Lists. - A lot of the work of Affinity happens within Lists. A **List** is a spreadsheet-like collection of rows tied to Persons, Companies, or Opportunities. - Each row on a List is a **List Entry**. A List Entry contains data and metadata about a given Person, Company, or Opportunity in the context of a List. This includes list-specific field data, and information about who added the row to the List and when. - Do note that a given entity can be added to a List more than once, i.e., it can have multiple List Entries on the same List. These List Entries can have different list-specific field data and List Entry-level metadata. - Each column on a List maps to a **Field**. Fields and field data also show up within Affinity profile pages, extensions, and integrations. - Some Fields are scoped to a single List — These are **list-specific fields**, and in the API, their data can only be accessed through the List Entry resource. \"Global\" data from other Fields can be accessed both through the Person/Company/Opportunity resource and the List Entry resource. ## Working with Field Data ### Field Types and IDs There are a few types of Fields in Affinity, differentiated by the scope and source of their data: | Field Type | Description | Example Fields | Field ID Pattern | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | `enriched` | Firmographic, funding, and people Fields populated by Affinity. These can be \"Affinity Data\" Fields or come from distinct data partners. | \"Affinity Data: Description\", \"Dealroom: Number of Employees\" | A string representing the enrichment source, followed by the field name, e.g. `affinity-data-description` or `dealroom-number-of-employees`. | | `list` | Fields that are specific to the context of a given list. These can only be accessed through `*_/list-entries` endpoints in this version of the API. | Default \"Status\" and \"Amount\" columns, custom columns that pertain to a given List of deals or founders | `field-`, followed by a unique integer, e.g. `field-1234` | | `global` | Fields that persist across an Affinity account and are not list-specific. | \"My Firm\'s Founder Scoring Column\" | `field-`, followed by a unique integer, e.g. `field-1234` | | `relationship-intelligence` | Fields populated by Affinity from users\' email and calendar data that provide insight into your firm\'s relationship with a given Person/Company/Opportunity. | \"Source of Introduction\", \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", \"Last Contact\" | A string similar to the field\'s name in-product, e.g. `source-of-introduction` | ### Field Value Types Field data can take a variety of shapes. These value types are described in the Affinity Help Center [here](https://support.affinity.co/hc/en-us/articles/115001608232-How-to-create-a-new-column-in-a-list). Here is a list of the same value types, as represented in this API. Notice how array types end with `-multi`: | Single Type | Array Type | | ------------------- | ------------------------- | | `text` | Not supported in Affinity | | `number` | `number-multi` | | `datetime` | Not supported in Affinity | | `location` | `location-multi` | | `dropdown` | `dropdown-multi` | | `ranked-dropdown` | Not supported in Affinity | | `person` | `person-multi` | | `company` | `company-multi` | | `filterable-text`\\* | `filterable-text-multi`\\* | \\*Please note that `filterable-text` and `filterable-text-multi` are special types that operate similarly to `dropdown` and `dropdown-multi`. They are reserved for Affinity-populated Fields, and users cannot create Fields with these types. When an array-typed value has no data in it, the API will return `null` (rather than an empty array). ### Retrieving Field Data To retrieve field data on companies, persons, or opportunities, call GET `/v2/companies`, GET `/v2/persons`, or one of our GET `*_/list-entries` endpoints. (Note that Opportunities only have list-specific Fields, so all their field data will live on the `*_/list-entries` endpoints.) For most of these endpoints, you will need to specify the Fields for which you want data returned via the `fieldIds` or `fieldTypes` parameter — Otherwise, entities will be returned without any field data attached. The GET `/v2/companies` and `/v2/persons` endpoints can return entities with enriched, global, and relationship intelligence field data attached, but do not support list-specific field data. **To get comprehensive field data including list-specific field data on Companies and Persons, use the GET `*_/list-entries` endpoints.** ### Specifying Desired Fields (Field Selection) As mentioned above, you will need to specify the Fields (either by ID or by Type) for which you want data returned when using the following endpoints: - GET `/v2/companies` - GET `/v2/companies/{id}` - GET `/v2/persons` - GET `/v2/persons/{id}` - GET `/v2/lists/{listId}/list-entries` Each of these endpoints has a `fieldIds` parameter that accepts an array of Field IDs, and a `fieldTypes` parameter that accepts an array of Field Types. Use the GET `*_/fields` endpoints to get Field IDs, Field Types, and other Field-level metadata: - Call GET `/v2/companies/fields` and `/v2/persons/fields` to get a list of the enriched, global, and relationship intelligence (AKA non-list-specific) Fields that exist on Companies and Persons, respectively. These are the Fields whose values are available to pull via GET `/v2/companies`, GET `/v2/companies/{id}`, GET `/v2/persons`, and `/v2/persons/{id}`. - Call GET `/v2/lists/{listId}/fields` to get a list of the enriched, global, relationship intelligence, **and list-specific** Fields for a given List. These are the Fields whose values are available to pull via GET `/v2/lists/{listId}/list-entries`. The following endpoints don\'t require field selection: - GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` — See below. This endpoint returns just the field data that has been pulled into the given Saved View via UI. - GET `/v2/companies/{id}/list-entries` and GET `/v2/persons/{id}/list-entries` — These endpoints return comprehensive field data for the given person or company in the context of each List Entry. ### Saved Views A Saved View allows a user to configure the Fields they want to see in the UI for a given List, and set filters and sorts on the rows on that List. A List can have multiple Saved Views. In the context of this API, Saved Views can be useful for specifying the exact Fields for which data is needed. The `*_/saved-views/{viewId}/list-entries` endpoint also respects the filters that have been set on the given Saved View in the Affinity web app. (It does not, however, respect sorts just yet.) ### Partner Data Restrictions This API supports pulling data from [Affinity Data](https://support.affinity.co/hc/en-us/articles/360058255052-Affinity-Data) fields and select [Dealroom fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22SVH7TJR3DJV3NQDE9HQ). Due the agreements we have with some of our data partners, the API does not expose data from the following sources: - Crunchbase, including Crunchbase UUID - Pitchbook - [Dealroom \"exclusive\" fields](https://support.affinity.co/hc/en-us/articles/6106558518797-Dealroom-co-data-in-Affinity#h_01G2N22YEAZJ5TC1X9ENKZFWF5) ## A Note on Nested Associations Some GET endpoints return \"association\" data under `fields`. For example, the Persons GET endpoints return data about which Companies a Person is associated with in Affinity. The Opportunities GET endpoints return similar data about associated Companies and Persons. The List Entries GET endpoints also return this data for Person and Opportunity List Entries. The API truncates these nested arrays of Persons or Companies **at 100 entries**. For example, if an Opportunity is associated with 200 Persons in Affinity, only 100 of those Persons will be returned by the GET `/opportunities` or `/opportunities/{id}` endpoint. # User Guides ## A Tour of Our GET Endpoints | Desired Data | Relevant Endpoints | Notes | | ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | Company/Person/Opportunity rows from a List | Grab the List’s ID from its URL in the Affinity web app, then hit GET `/v2/lists/{listId}/list-entries` | Data returned will be restricted to the rows on the requested List | | Company/Person/Opportunity rows from a Saved View | In the Affinity web app, navigate to a List and [create a Saved View](https://support.affinity.co/hc/en-us/articles/115001508572-How-to-leverage-saved-views-within-a-list) with the desired field data and filters on it. Grab the List and Saved View IDs from the web app URL, then hit GET `/v2/lists/{listId}/saved-views/{viewId}/list-entries` | Data returned will be restricted to the rows and columns on the requested Saved View | | Full rolodex of Companies or Persons in Affinity | GET `/v2/companies`, GET `/v2/persons` | Data from list-specific Fields will not be returned | | All the rows for a given Company or Person across all Lists | GET `/v2/companies/{id}/list-entries`, GET `/v2/persons/{id}/list-entries` | | | Metadata on Fields, including Field IDs | GET `/v2/companies/fields`, GET `/v2/persons/fields`, GET `/v2/lists/{listId}/fields` | Metadata on list-specific Fields will only be returned by GET `/v2/lists/{listId}/fields` | | Metadata on Lists or Saved Views | GET `/v2/lists`, GET `/v2/lists/{listId}/saved-views` | | | Opportunity data | GET `/v2/opportunities` will only return Opportunity names and List IDs. For comprehensive Opportunity data, hit GET `/v2/lists/{listId}/list-entries` for an Opportunity List | | Tip: The ID for a List, Saved View, Person, Company, or Opportunity can always be found in its Affinity web app URL. # Changelog ## September 25th, 2024 - Upgrade schema to Openapi 3.1 ## August 5, 2024 - Correct `opp` to `opportunity` to match documentation for the `List` `type` property. ## July 24, 2024 - More accurate documentation for response properties that are enums — Enums with `null` as a possible value will have it listed as one. ## March 25, 2024 - Added the ability to retrieve the date and other details of your firm\'s \"First Email\", \"Last Email\", \"First Event\", \"Last Event\", \"Next Event\", \"First Chat Message\", \"Last Chat Message\", and \"Last Contact\" with a given entity. Use these timestamps to add relationship context to your applications, and to identify founders and companies that need investors\' attention. - Endpoints that previously required a `fieldIds` parameter to return field data, now accept either `fieldIds` or `fieldTypes`, and will return field data accordingly. See the [Specifying Desired Fields (Field Selection)](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. The new `fieldTypes` parameter should make field data retrieval easier for users looking to pull data from many similar Fields at a time. ## January 4, 2023 - Most endpoints that return field data now require the user to use the `fieldIds` parameter to specify which Fields they want data for. Without `fieldIds` specified, these endpoints will return basic entity data but not field data. ## December 12, 2023 - Added the ability to retrieve metadata (e.g. ID, name, type, enrichment source, and data type) on Fields. See the [Retrieving Field Metadata](#section/Data-Model/Working-with-Field-Data) section of these docs for more information. * * OpenAPI spec version: 2.0.0 * Contact: support@affinity.co diff --git a/src/v2/generated/models/all.ts b/src/v2/generated/models/all.ts index bb88ec1..b01e638 100644 --- a/src/v2/generated/models/all.ts +++ b/src/v2/generated/models/all.ts @@ -10,14 +10,11 @@ export * from '../models/CompanyData.ts' export * from '../models/CompanyListEntry.ts' export * from '../models/CompanyPaged.ts' export * from '../models/CompanyValue.ts' -export * from '../models/ConflictError.ts' export * from '../models/DateValue.ts' export * from '../models/Dropdown.ts' export * from '../models/DropdownValue.ts' export * from '../models/DropdownsValue.ts' export * from '../models/Email.ts' -export * from '../models/EmptyMessageBodyError.ts' -export * from '../models/Errors.ts' export * from '../models/Field.ts' export * from '../models/FieldMetadata.ts' export * from '../models/FieldMetadataPaged.ts' @@ -26,13 +23,9 @@ export * from '../models/FloatValue.ts' export * from '../models/FloatsValue.ts' export * from '../models/FormulaNumber.ts' export * from '../models/FormulaValue.ts' -export * from '../models/GenericError.ts' export * from '../models/Grant.ts' export * from '../models/Interaction.ts' export * from '../models/InteractionValue.ts' -export * from '../models/InvalidAcceptHeaderError.ts' -export * from '../models/InvalidMessageBodyError.ts' -export * from '../models/InvalidVersionHeaderError.ts' export * from '../models/List.ts' export * from '../models/ListEntry.ts' export * from '../models/ListEntryPaged.ts' @@ -45,8 +38,6 @@ export * from '../models/Location.ts' export * from '../models/LocationValue.ts' export * from '../models/LocationsValue.ts' export * from '../models/Meeting.ts' -export * from '../models/MethodNotAllowedError.ts' -export * from '../models/ModelError.ts' export * from '../models/NotFoundError.ts' export * from '../models/NotFoundErrors.ts' export * from '../models/Opportunity.ts' @@ -63,14 +54,11 @@ export * from '../models/PersonsValue.ts' export * from '../models/PhoneCall.ts' export * from '../models/RankedDropdown.ts' export * from '../models/RankedDropdownValue.ts' -export * from '../models/RateLimitError.ts' export * from '../models/SavedView.ts' export * from '../models/SavedViewPaged.ts' -export * from '../models/ServerError.ts' export * from '../models/Tenant.ts' export * from '../models/TextValue.ts' export * from '../models/TextsValue.ts' -export * from '../models/TooManyMultipartFilesError.ts' export * from '../models/User.ts' export * from '../models/ValidationError.ts' export * from '../models/ValidationErrors.ts' diff --git a/src/v2/generated/types/ObjectParamAPI.ts b/src/v2/generated/types/ObjectParamAPI.ts index 54218d8..49d5099 100644 --- a/src/v2/generated/types/ObjectParamAPI.ts +++ b/src/v2/generated/types/ObjectParamAPI.ts @@ -13,14 +13,11 @@ import { CompanyData } from '../models/CompanyData.ts'; import { CompanyListEntry } from '../models/CompanyListEntry.ts'; import { CompanyPaged } from '../models/CompanyPaged.ts'; import { CompanyValue } from '../models/CompanyValue.ts'; -import { ConflictError } from '../models/ConflictError.ts'; import { DateValue } from '../models/DateValue.ts'; import { Dropdown } from '../models/Dropdown.ts'; import { DropdownValue } from '../models/DropdownValue.ts'; import { DropdownsValue } from '../models/DropdownsValue.ts'; import { Email } from '../models/Email.ts'; -import { EmptyMessageBodyError } from '../models/EmptyMessageBodyError.ts'; -import { Errors } from '../models/Errors.ts'; import { Field } from '../models/Field.ts'; import { FieldMetadata } from '../models/FieldMetadata.ts'; import { FieldMetadataPaged } from '../models/FieldMetadataPaged.ts'; @@ -29,13 +26,9 @@ import { FloatValue } from '../models/FloatValue.ts'; import { FloatsValue } from '../models/FloatsValue.ts'; import { FormulaNumber } from '../models/FormulaNumber.ts'; import { FormulaValue } from '../models/FormulaValue.ts'; -import { GenericError } from '../models/GenericError.ts'; import { Grant } from '../models/Grant.ts'; import { Interaction } from '../models/Interaction.ts'; import { InteractionValue } from '../models/InteractionValue.ts'; -import { InvalidAcceptHeaderError } from '../models/InvalidAcceptHeaderError.ts'; -import { InvalidMessageBodyError } from '../models/InvalidMessageBodyError.ts'; -import { InvalidVersionHeaderError } from '../models/InvalidVersionHeaderError.ts'; import { List } from '../models/List.ts'; import { ListEntry } from '../models/ListEntry.ts'; import { ListEntryPaged } from '../models/ListEntryPaged.ts'; @@ -48,8 +41,6 @@ import { Location } from '../models/Location.ts'; import { LocationValue } from '../models/LocationValue.ts'; import { LocationsValue } from '../models/LocationsValue.ts'; import { Meeting } from '../models/Meeting.ts'; -import { MethodNotAllowedError } from '../models/MethodNotAllowedError.ts'; -import { ModelError } from '../models/ModelError.ts'; import { NotFoundError } from '../models/NotFoundError.ts'; import { NotFoundErrors } from '../models/NotFoundErrors.ts'; import { Opportunity } from '../models/Opportunity.ts'; @@ -66,14 +57,11 @@ import { PersonsValue } from '../models/PersonsValue.ts'; import { PhoneCall } from '../models/PhoneCall.ts'; import { RankedDropdown } from '../models/RankedDropdown.ts'; import { RankedDropdownValue } from '../models/RankedDropdownValue.ts'; -import { RateLimitError } from '../models/RateLimitError.ts'; import { SavedView } from '../models/SavedView.ts'; import { SavedViewPaged } from '../models/SavedViewPaged.ts'; -import { ServerError } from '../models/ServerError.ts'; import { Tenant } from '../models/Tenant.ts'; import { TextValue } from '../models/TextValue.ts'; import { TextsValue } from '../models/TextsValue.ts'; -import { TooManyMultipartFilesError } from '../models/TooManyMultipartFilesError.ts'; import { User } from '../models/User.ts'; import { ValidationError } from '../models/ValidationError.ts'; import { ValidationErrors } from '../models/ValidationErrors.ts'; diff --git a/src/v2/generated/types/ObservableAPI.ts b/src/v2/generated/types/ObservableAPI.ts index a3f6e8b..3bb42f6 100644 --- a/src/v2/generated/types/ObservableAPI.ts +++ b/src/v2/generated/types/ObservableAPI.ts @@ -14,14 +14,11 @@ import { CompanyData } from '../models/CompanyData.ts'; import { CompanyListEntry } from '../models/CompanyListEntry.ts'; import { CompanyPaged } from '../models/CompanyPaged.ts'; import { CompanyValue } from '../models/CompanyValue.ts'; -import { ConflictError } from '../models/ConflictError.ts'; import { DateValue } from '../models/DateValue.ts'; import { Dropdown } from '../models/Dropdown.ts'; import { DropdownValue } from '../models/DropdownValue.ts'; import { DropdownsValue } from '../models/DropdownsValue.ts'; import { Email } from '../models/Email.ts'; -import { EmptyMessageBodyError } from '../models/EmptyMessageBodyError.ts'; -import { Errors } from '../models/Errors.ts'; import { Field } from '../models/Field.ts'; import { FieldMetadata } from '../models/FieldMetadata.ts'; import { FieldMetadataPaged } from '../models/FieldMetadataPaged.ts'; @@ -30,13 +27,9 @@ import { FloatValue } from '../models/FloatValue.ts'; import { FloatsValue } from '../models/FloatsValue.ts'; import { FormulaNumber } from '../models/FormulaNumber.ts'; import { FormulaValue } from '../models/FormulaValue.ts'; -import { GenericError } from '../models/GenericError.ts'; import { Grant } from '../models/Grant.ts'; import { Interaction } from '../models/Interaction.ts'; import { InteractionValue } from '../models/InteractionValue.ts'; -import { InvalidAcceptHeaderError } from '../models/InvalidAcceptHeaderError.ts'; -import { InvalidMessageBodyError } from '../models/InvalidMessageBodyError.ts'; -import { InvalidVersionHeaderError } from '../models/InvalidVersionHeaderError.ts'; import { List } from '../models/List.ts'; import { ListEntry } from '../models/ListEntry.ts'; import { ListEntryPaged } from '../models/ListEntryPaged.ts'; @@ -49,8 +42,6 @@ import { Location } from '../models/Location.ts'; import { LocationValue } from '../models/LocationValue.ts'; import { LocationsValue } from '../models/LocationsValue.ts'; import { Meeting } from '../models/Meeting.ts'; -import { MethodNotAllowedError } from '../models/MethodNotAllowedError.ts'; -import { ModelError } from '../models/ModelError.ts'; import { NotFoundError } from '../models/NotFoundError.ts'; import { NotFoundErrors } from '../models/NotFoundErrors.ts'; import { Opportunity } from '../models/Opportunity.ts'; @@ -67,14 +58,11 @@ import { PersonsValue } from '../models/PersonsValue.ts'; import { PhoneCall } from '../models/PhoneCall.ts'; import { RankedDropdown } from '../models/RankedDropdown.ts'; import { RankedDropdownValue } from '../models/RankedDropdownValue.ts'; -import { RateLimitError } from '../models/RateLimitError.ts'; import { SavedView } from '../models/SavedView.ts'; import { SavedViewPaged } from '../models/SavedViewPaged.ts'; -import { ServerError } from '../models/ServerError.ts'; import { Tenant } from '../models/Tenant.ts'; import { TextValue } from '../models/TextValue.ts'; import { TextsValue } from '../models/TextsValue.ts'; -import { TooManyMultipartFilesError } from '../models/TooManyMultipartFilesError.ts'; import { User } from '../models/User.ts'; import { ValidationError } from '../models/ValidationError.ts'; import { ValidationErrors } from '../models/ValidationErrors.ts'; diff --git a/src/v2/generated/types/PromiseAPI.ts b/src/v2/generated/types/PromiseAPI.ts index 5c4fa4f..712b0a0 100644 --- a/src/v2/generated/types/PromiseAPI.ts +++ b/src/v2/generated/types/PromiseAPI.ts @@ -13,14 +13,11 @@ import { CompanyData } from '../models/CompanyData.ts'; import { CompanyListEntry } from '../models/CompanyListEntry.ts'; import { CompanyPaged } from '../models/CompanyPaged.ts'; import { CompanyValue } from '../models/CompanyValue.ts'; -import { ConflictError } from '../models/ConflictError.ts'; import { DateValue } from '../models/DateValue.ts'; import { Dropdown } from '../models/Dropdown.ts'; import { DropdownValue } from '../models/DropdownValue.ts'; import { DropdownsValue } from '../models/DropdownsValue.ts'; import { Email } from '../models/Email.ts'; -import { EmptyMessageBodyError } from '../models/EmptyMessageBodyError.ts'; -import { Errors } from '../models/Errors.ts'; import { Field } from '../models/Field.ts'; import { FieldMetadata } from '../models/FieldMetadata.ts'; import { FieldMetadataPaged } from '../models/FieldMetadataPaged.ts'; @@ -29,13 +26,9 @@ import { FloatValue } from '../models/FloatValue.ts'; import { FloatsValue } from '../models/FloatsValue.ts'; import { FormulaNumber } from '../models/FormulaNumber.ts'; import { FormulaValue } from '../models/FormulaValue.ts'; -import { GenericError } from '../models/GenericError.ts'; import { Grant } from '../models/Grant.ts'; import { Interaction } from '../models/Interaction.ts'; import { InteractionValue } from '../models/InteractionValue.ts'; -import { InvalidAcceptHeaderError } from '../models/InvalidAcceptHeaderError.ts'; -import { InvalidMessageBodyError } from '../models/InvalidMessageBodyError.ts'; -import { InvalidVersionHeaderError } from '../models/InvalidVersionHeaderError.ts'; import { List } from '../models/List.ts'; import { ListEntry } from '../models/ListEntry.ts'; import { ListEntryPaged } from '../models/ListEntryPaged.ts'; @@ -48,8 +41,6 @@ import { Location } from '../models/Location.ts'; import { LocationValue } from '../models/LocationValue.ts'; import { LocationsValue } from '../models/LocationsValue.ts'; import { Meeting } from '../models/Meeting.ts'; -import { MethodNotAllowedError } from '../models/MethodNotAllowedError.ts'; -import { ModelError } from '../models/ModelError.ts'; import { NotFoundError } from '../models/NotFoundError.ts'; import { NotFoundErrors } from '../models/NotFoundErrors.ts'; import { Opportunity } from '../models/Opportunity.ts'; @@ -66,14 +57,11 @@ import { PersonsValue } from '../models/PersonsValue.ts'; import { PhoneCall } from '../models/PhoneCall.ts'; import { RankedDropdown } from '../models/RankedDropdown.ts'; import { RankedDropdownValue } from '../models/RankedDropdownValue.ts'; -import { RateLimitError } from '../models/RateLimitError.ts'; import { SavedView } from '../models/SavedView.ts'; import { SavedViewPaged } from '../models/SavedViewPaged.ts'; -import { ServerError } from '../models/ServerError.ts'; import { Tenant } from '../models/Tenant.ts'; import { TextValue } from '../models/TextValue.ts'; import { TextsValue } from '../models/TextsValue.ts'; -import { TooManyMultipartFilesError } from '../models/TooManyMultipartFilesError.ts'; import { User } from '../models/User.ts'; import { ValidationError } from '../models/ValidationError.ts'; import { ValidationErrors } from '../models/ValidationErrors.ts';