attio-js
Version:
Developer-friendly & type-safe JS/TS SDK based on the official OpenAPI spec of Attio.
363 lines (263 loc) • 25.4 kB
Markdown
(*notes*)
Notes are rich text documents that reference a single parent record.
* [list](
* [create](
* [get](
* [delete](
List notes for all records or for a specific record.
Required scopes: `note:read`, `object_configuration:read`, `record_permission:read`.
```typescript
import { Attio } from "attio-js";
const attio = new Attio({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const result = await attio.notes.list({
limit: 10,
offset: 5,
parentObject: "people",
parentRecordId: "891dcbfc-9141-415d-9b2a-2238a6cc012d",
});
// Handle the result
console.log(result);
}
run();
```
The standalone function version of this method:
```typescript
import { AttioCore } from "attio-js/core.js";
import { notesList } from "attio-js/funcs/notesList.js";
// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const res = await notesList(attio, {
limit: 10,
offset: 5,
parentObject: "people",
parentRecordId: "891dcbfc-9141-415d-9b2a-2238a6cc012d",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
```
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request` | [operations.GetV2NotesRequest](../../models/operations/getv2notesrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
**Promise\<[operations.GetV2NotesResponse](../../models/operations/getv2notesresponse.md)\>**
| Error Type | Status Code | Content Type |
| -------------------------------------- | -------------------------------------- | -------------------------------------- |
| errors.GetV2ObjectsObjectNotFoundError | 404 | application/json |
| errors.APIError | 4XX, 5XX | \*/\* |
Creates a new note for a given record.
Required scopes: `note:read-write`, `object_configuration:read`, `record_permission:read`.
```typescript
import { Attio } from "attio-js";
const attio = new Attio({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const result = await attio.notes.create({
data: {
parentObject: "people",
parentRecordId: "891dcbfc-9141-415d-9b2a-2238a6cc012d",
title: "Initial Prospecting Call Summary",
format: "plaintext",
content: "Introduction\n" +
"Date and time of the call\n" +
"Participants\n" +
"Purpose of the call\n" +
"Customer Background\n" +
"Company overview (industry, size, location)\n" +
"Key business challenges\n" +
"Current software solutions (if any) and pain points",
createdAt: "2023-01-01T15:00:00.000000000Z",
},
});
// Handle the result
console.log(result);
}
run();
```
The standalone function version of this method:
```typescript
import { AttioCore } from "attio-js/core.js";
import { notesCreate } from "attio-js/funcs/notesCreate.js";
// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const res = await notesCreate(attio, {
data: {
parentObject: "people",
parentRecordId: "891dcbfc-9141-415d-9b2a-2238a6cc012d",
title: "Initial Prospecting Call Summary",
format: "plaintext",
content: "Introduction\n" +
"Date and time of the call\n" +
"Participants\n" +
"Purpose of the call\n" +
"Customer Background\n" +
"Company overview (industry, size, location)\n" +
"Key business challenges\n" +
"Current software solutions (if any) and pain points",
createdAt: "2023-01-01T15:00:00.000000000Z",
},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
```
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request` | [operations.PostV2NotesRequest](../../models/operations/postv2notesrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
**Promise\<[operations.PostV2NotesResponse](../../models/operations/postv2notesresponse.md)\>**
| Error Type | Status Code | Content Type |
| -------------------------------------- | -------------------------------------- | -------------------------------------- |
| errors.GetV2ObjectsObjectNotFoundError | 404 | application/json |
| errors.APIError | 4XX, 5XX | \*/\* |
Get a single note by ID.
Required scopes: `note:read`, `object_configuration:read`, `record_permission:read`.
```typescript
import { Attio } from "attio-js";
const attio = new Attio({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const result = await attio.notes.get({
noteId: "ff3f3bd4-40f4-4f80-8187-cd02385af424",
});
// Handle the result
console.log(result);
}
run();
```
The standalone function version of this method:
```typescript
import { AttioCore } from "attio-js/core.js";
import { notesGet } from "attio-js/funcs/notesGet.js";
// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const res = await notesGet(attio, {
noteId: "ff3f3bd4-40f4-4f80-8187-cd02385af424",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
```
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request` | [operations.GetV2NotesNoteIdRequest](../../models/operations/getv2notesnoteidrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
**Promise\<[operations.GetV2NotesNoteIdResponse](../../models/operations/getv2notesnoteidresponse.md)\>**
| Error Type | Status Code | Content Type |
| ------------------------------------ | ------------------------------------ | ------------------------------------ |
| errors.GetV2NotesNoteIdNotFoundError | 404 | application/json |
| errors.APIError | 4XX, 5XX | \*/\* |
Delete a single note by ID.
Required scopes: `note:read-write`.
```typescript
import { Attio } from "attio-js";
const attio = new Attio({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const result = await attio.notes.delete({
noteId: "ff3f3bd4-40f4-4f80-8187-cd02385af424",
});
// Handle the result
console.log(result);
}
run();
```
The standalone function version of this method:
```typescript
import { AttioCore } from "attio-js/core.js";
import { notesDelete } from "attio-js/funcs/notesDelete.js";
// Use `AttioCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const attio = new AttioCore({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const res = await notesDelete(attio, {
noteId: "ff3f3bd4-40f4-4f80-8187-cd02385af424",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
```
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request` | [operations.DeleteV2NotesNoteIdRequest](../../models/operations/deletev2notesnoteidrequest.md) | :heavy_check_mark: | The request object to use for the request. |
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
**Promise\<[operations.DeleteV2NotesNoteIdResponse](../../models/operations/deletev2notesnoteidresponse.md)\>**
| Error Type | Status Code | Content Type |
| ------------------------------------ | ------------------------------------ | ------------------------------------ |
| errors.GetV2NotesNoteIdNotFoundError | 404 | application/json |
| errors.APIError | 4XX, 5XX | \*/\* |