curl --request POST \
--url https://api.affinity.co/v2/notes/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "Series B terms",
"noteIds": [
1,
2
],
"limit": 20
}
'import requests
url = "https://api.affinity.co/v2/notes/search"
payload = {
"prompt": "Series B terms",
"noteIds": [1, 2],
"limit": 20
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({prompt: 'Series B terms', noteIds: [1, 2], limit: 20})
};
fetch('https://api.affinity.co/v2/notes/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.affinity.co/v2/notes/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'Series B terms',
'noteIds' => [
1,
2
],
'limit' => 20
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.affinity.co/v2/notes/search"
payload := strings.NewReader("{\n \"prompt\": \"Series B terms\",\n \"noteIds\": [\n 1,\n 2\n ],\n \"limit\": 20\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.affinity.co/v2/notes/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"Series B terms\",\n \"noteIds\": [\n 1,\n 2\n ],\n \"limit\": 20\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.affinity.co/v2/notes/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"Series B terms\",\n \"noteIds\": [\n 1,\n 2\n ],\n \"limit\": 20\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"note": {
"id": 1,
"kind": "note"
},
"preview": "We discussed the Series B terms with the founding team last Thursday."
}
]
}{
"errors": [
{
"code": "bad-request",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "not-found",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authentication",
"message": "<string>"
}
]
}Search Notes by Keyword
Search notes by keyword. The scope of the search is controlled by the request body:
- Provide
noteIdsto limit the search to specific notes. - Provide
companyIdto limit the search to notes associated with a specific company. - Omit both to search across your entire account.
noteIds and companyId are mutually exclusive.
Returns up to limit notes ordered by relevance. Prompts with no strong matches may
still return low-relevance results.
Each result contains a matched note and a single representative excerpt (a matching passage from that note). Even if a note contains multiple matching passages, it appears exactly once in the response with one excerpt.
curl --request POST \
--url https://api.affinity.co/v2/notes/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "Series B terms",
"noteIds": [
1,
2
],
"limit": 20
}
'import requests
url = "https://api.affinity.co/v2/notes/search"
payload = {
"prompt": "Series B terms",
"noteIds": [1, 2],
"limit": 20
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({prompt: 'Series B terms', noteIds: [1, 2], limit: 20})
};
fetch('https://api.affinity.co/v2/notes/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.affinity.co/v2/notes/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'Series B terms',
'noteIds' => [
1,
2
],
'limit' => 20
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.affinity.co/v2/notes/search"
payload := strings.NewReader("{\n \"prompt\": \"Series B terms\",\n \"noteIds\": [\n 1,\n 2\n ],\n \"limit\": 20\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.affinity.co/v2/notes/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"Series B terms\",\n \"noteIds\": [\n 1,\n 2\n ],\n \"limit\": 20\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.affinity.co/v2/notes/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"Series B terms\",\n \"noteIds\": [\n 1,\n 2\n ],\n \"limit\": 20\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"note": {
"id": 1,
"kind": "note"
},
"preview": "We discussed the Series B terms with the founding team last Thursday."
}
]
}{
"errors": [
{
"code": "bad-request",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "not-found",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authentication",
"message": "<string>"
}
]
}Authorizations
A static Affinity API key, presented as a bearer token.
Body
- Note Keyword Search Criteria (org-wide or by note IDs)
- Note Keyword Search Criteria (by company)
Search all notes in the org, or limit to specific note IDs.
The search query. Returns up to limit notes ordered by relevance. Prompts with
no strong matches may still return low-relevance results.
3 - 500"Series B terms"
Limit search to these specific notes. Omit for org-wide search.
1001 <= x <= 2147483647[1, 2]
Maximum number of notes to return.
1 <= x <= 10020
Response
Created
Results of a keyword search over notes.
Matching note results, one per note, ordered by relevance.
100Show child attributes
Show child attributes
Was this page helpful?