Files

Search Files by Keyword

Changed on

Search files by keyword. The scope of the search is controlled by the request body:

  • Provide fileIds to limit the search to specific files.
  • Provide companyId to limit the search to files associated with a specific company.
  • Omit both to search across your entire account.

fileIds and companyId are mutually exclusive.

Returns up to limit files ordered by relevance. Prompts with no strong matches may still return low-relevance results.

Each result contains a matched file and a single representative excerpt (a matching passage from that file). Even if a file contains multiple matching passages, it appears exactly once in the response with one excerpt.

post/v2/files/search

Request

  • Base URL
    https://api.affinity.co
  • URL
    https://api.affinity.co/v2/files/search
  • Auth
    • HTTP bearer
    • or OAuth 2
      Authorization code: https://login.affinity.co/auth/oauth2/authorize
      Token URL: https://login.affinity.co/auth/oauth2/token scopes: api.read

Request body

OR

Example request

{
  "prompt": "revenue projections pitch deck",
  "fileIds": [
    1,
    2
  ],
  "limit": 20
}

Response

Created

Example response

{
  "data": [
    {
      "file": {
        "id": 1,
        "name": "pitch-deck-q3-2024.pdf"
      },
      "pageNumber": 3,
      "preview": "Projected ARR of $12M by end of Q4 2024, with 80% gross margin."
    }
  ]
}

Changes

    • info

      the endpoint scheme security apiKeyAuth was added to the API

    • info

      the endpoint scheme security oauth2 was added to the API

    • info

      added authentication authorization bad-request conflict method-not-allowed not-acceptable not-found not-implemented rate-limit server timeout unprocessable-entity unsupported-media-type validation discriminator mapping keys to the / response property for the response status

    • info

      added bad-request validation discriminator mapping keys to the / response property for the response status