attio-js
Version:
Developer-friendly & type-safe JS/TS SDK based on the official OpenAPI spec of Attio.
347 lines (247 loc) • 24.2 kB
Markdown
(*objects*)
Objects are the core data models inside of Attio. They contain standard objects, such as [people](/docs/standard-objects-people), [companies](/docs/standard-objects-companies) or [deals](/docs/standard-objects-deals), and custom objects that are specific to your use-case. See our [data model guide](/docs/data-model) for more information.
* [list](
* [create](
* [get](
* [partialUpdate](
Lists all system-defined and user-defined objects in your workspace.
Required scopes: `object_configuration:read`.
```typescript
import { Attio } from "attio-js";
const attio = new Attio({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const result = await attio.objects.list();
// Handle the result
console.log(result);
}
run();
```
The standalone function version of this method:
```typescript
import { AttioCore } from "attio-js/core.js";
import { objectsList } from "attio-js/funcs/objectsList.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 objectsList(attio);
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
```
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `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.GetV2ObjectsResponse](../../models/operations/getv2objectsresponse.md)\>**
| Error Type | Status Code | Content Type |
| --------------- | --------------- | --------------- |
| errors.APIError | 4XX, 5XX | \*/\* |
Creates a new custom object in your workspace.
Required scopes: `object_configuration: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.objects.create({
data: {
apiSlug: "people",
singularNoun: "Person",
pluralNoun: "People",
},
});
// Handle the result
console.log(result);
}
run();
```
The standalone function version of this method:
```typescript
import { AttioCore } from "attio-js/core.js";
import { objectsCreate } from "attio-js/funcs/objectsCreate.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 objectsCreate(attio, {
data: {
apiSlug: "people",
singularNoun: "Person",
pluralNoun: "People",
},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
```
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request` | [operations.PostV2ObjectsRequest](../../models/operations/postv2objectsrequest.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.PostV2ObjectsResponse](../../models/operations/postv2objectsresponse.md)\>**
| Error Type | Status Code | Content Type |
| ------------------------------------- | ------------------------------------- | ------------------------------------- |
| errors.PostV2ObjectsSlugConflictError | 409 | application/json |
| errors.APIError | 4XX, 5XX | \*/\* |
Gets a single object by its `object_id` or slug.
Required scopes: `object_configuration:read`.
```typescript
import { Attio } from "attio-js";
const attio = new Attio({
apiKey: process.env["ATTIO_API_KEY"] ?? "",
});
async function run() {
const result = await attio.objects.get({
object: "people",
});
// Handle the result
console.log(result);
}
run();
```
The standalone function version of this method:
```typescript
import { AttioCore } from "attio-js/core.js";
import { objectsGet } from "attio-js/funcs/objectsGet.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 objectsGet(attio, {
object: "people",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
```
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request` | [operations.GetV2ObjectsObjectRequest](../../models/operations/getv2objectsobjectrequest.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.GetV2ObjectsObjectResponse](../../models/operations/getv2objectsobjectresponse.md)\>**
| Error Type | Status Code | Content Type |
| -------------------------------------- | -------------------------------------- | -------------------------------------- |
| errors.GetV2ObjectsObjectNotFoundError | 404 | application/json |
| errors.APIError | 4XX, 5XX | \*/\* |
Updates a single object. The object to be updated is identified by its `object_id`.
Required scopes: `object_configuration: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.objects.partialUpdate({
object: "people",
requestBody: {
data: {
apiSlug: "people",
singularNoun: "Person",
pluralNoun: "People",
},
},
});
// Handle the result
console.log(result);
}
run();
```
The standalone function version of this method:
```typescript
import { AttioCore } from "attio-js/core.js";
import { objectsPartialUpdate } from "attio-js/funcs/objectsPartialUpdate.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 objectsPartialUpdate(attio, {
object: "people",
requestBody: {
data: {
apiSlug: "people",
singularNoun: "Person",
pluralNoun: "People",
},
},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
```
| Parameter | Type | Required | Description |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `request` | [operations.PatchV2ObjectsObjectRequest](../../models/operations/patchv2objectsobjectrequest.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.PatchV2ObjectsObjectResponse](../../models/operations/patchv2objectsobjectresponse.md)\>**
| Error Type | Status Code | Content Type |
| ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- |
| errors.PatchV2ObjectsObjectValidationTypeError | 400 | application/json |
| errors.GetV2ObjectsObjectNotFoundError | 404 | application/json |
| errors.PatchV2ObjectsObjectSlugConflictError | 409 | application/json |
| errors.APIError | 4XX, 5XX | \*/\* |