> ## Documentation Index
> Fetch the complete documentation index at: https://developers.hubspot.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

---
id: ce1a207e-0b61-482f-9c66-86755d8e425d
---

# Using Object APIs

> Learn how to use the object API endpoints to create and manage records or activities.

export const PostmanCard = ({title, collectionId}) => {
  return <div className="card-condensed-cta">
      <Card title={title ? title : "Postman collection"} href={`https://app.getpostman.com/run-collection/${collectionId}`} horizontal={true} cta="Run in Postman" icon={<svg xmlns="http://www.w3.org/2000/svg" width={25} height={25} preserveAspectRatio="xMidYMid" viewBox="0 0 256 256">
              <path fill="#FF6C37" d="M254.953 144.253c8.959-70.131-40.569-134.248-110.572-143.206C74.378-7.912 10.005 41.616 1.047 111.619c-8.959 70.003 40.569 134.248 110.572 143.334 70.131 8.959 134.248-40.569 143.334-110.7Z" />
              <path fill="#FFF" d="m174.2 82.184-54.007 54.007-15.229-15.23c53.11-53.11 58.358-48.503 69.236-38.777Z" />
              <path fill="#FF6C37" d="M120.193 137.47c-.384 0-.64-.128-.895-.384l-15.358-15.229a1.237 1.237 0 0 1 0-1.792c54.007-54.006 59.638-48.887 71.028-38.649.255.256.383.512.383.896s-.128.64-.383.896l-54.007 53.878c-.128.256-.512.384-.768.384Zm-13.437-16.509 13.437 13.438 52.087-52.087c-9.47-8.446-15.87-11.006-65.524 38.65Z" />
              <path fill="#FFF" d="m135.679 151.676-14.718-14.718 54.007-54.006c14.46 14.59-7.167 38.265-39.29 68.724Z" />
              <path fill="#FF6C37" d="M135.679 152.956c-.384 0-.64-.128-.896-.384l-14.718-14.718c-.256-.256-.256-.512-.256-.896s.128-.64.384-.895L174.2 82.056a1.237 1.237 0 0 1 1.791 0 15.58 15.58 0 0 1 4.991 11.902c-.256 14.206-16.38 32.25-44.28 58.614-.383.256-.767.384-1.023.384Zm-12.926-15.998c8.19 8.319 11.646 11.646 12.926 12.926 21.5-20.476 42.36-41.464 42.488-55.926.128-3.327-1.152-6.655-3.327-9.214l-52.087 52.214Z" />
              <path fill="#FFF" d="m105.22 121.345 10.878 10.878c.256.256.256.512 0 .768-.128.128-.128.128-.256.128l-22.524 4.863c-1.152.128-2.175-.64-2.431-1.791-.128-.64.128-1.28.512-1.664l13.053-13.054c.256-.256.64-.384.768-.128Z" />
              <path fill="#FF6C37" d="M92.934 139.262c-1.92 0-3.327-1.536-3.327-3.455 0-.896.384-1.792 1.024-2.432l13.053-13.054c.768-.64 1.792-.64 2.56 0l10.878 10.878c.768.64.768 1.792 0 2.56-.256.256-.512.384-.896.512l-22.524 4.863c-.256 0-.512.128-.768.128Zm11.902-16.51-12.542 12.543c-.256.256-.383.64-.128 1.024.128.383.512.511.896.383l21.116-4.607-9.342-9.342Z" />
              <path fill="#FFF" d="M202.739 52.238c-8.191-7.935-21.373-7.679-29.307.64-7.935 8.318-7.679 21.372.64 29.306A20.678 20.678 0 0 0 199.155 85l-14.59-14.59 18.174-18.172Z" />
              <path fill="#FF6C37" d="M188.405 89.223c-12.158 0-22.012-9.854-22.012-22.012 0-12.158 9.854-22.012 22.012-22.012 5.631 0 11.134 2.176 15.23 6.143.255.256.383.512.383.896s-.128.64-.384.895L186.357 70.41l13.566 13.566c.512.512.512 1.28 0 1.792l-.256.256c-3.327 2.047-7.295 3.199-11.262 3.199Zm0-41.337c-10.75 0-19.452 8.703-19.324 19.453 0 10.75 8.702 19.452 19.452 19.324 2.944 0 5.887-.64 8.575-2.047l-13.438-13.31c-.256-.256-.384-.512-.384-.896s.128-.64.384-.895l17.149-17.15c-3.456-2.943-7.807-4.479-12.414-4.479Z" />
              <path fill="#FFF" d="m203.122 52.622-.255-.256-18.301 18.044 14.461 14.462c1.408-.896 2.816-1.92 3.967-3.072a20.51 20.51 0 0 0 .128-29.178Z" />
              <path fill="#FF6C37" d="M199.155 86.28c-.384 0-.64-.128-.896-.384l-14.589-14.59c-.256-.256-.384-.512-.384-.896s.128-.64.384-.895l18.173-18.173a1.237 1.237 0 0 1 1.791 0l.384.256c8.575 8.574 8.575 22.396.128 31.098-1.28 1.28-2.687 2.432-4.223 3.328-.384.128-.64.256-.768.256Zm-12.798-15.87 12.926 12.926c1.024-.64 2.048-1.536 2.816-2.304 7.294-7.294 7.678-19.196.64-26.875L186.357 70.41Z" />
              <path fill="#FFF" d="M176.375 84.488a7.879 7.879 0 0 0-11.134 0l-48.247 48.247 8.063 8.063 51.062-44.792c3.328-2.816 3.584-7.807.768-11.134-.256-.128-.384-.256-.512-.384Z" />
              <path fill="#FF6C37" d="M124.929 142.077c-.384 0-.64-.128-.896-.383l-8.063-8.063a1.237 1.237 0 0 1 0-1.792l48.247-48.247a9.115 9.115 0 0 1 12.926 0 9.115 9.115 0 0 1 0 12.926l-.384.384-51.063 44.792c-.128.255-.384.383-.767.383Zm-6.143-9.342 6.27 6.271 50.167-44.024c2.816-2.304 3.072-6.527.768-9.342-2.303-2.816-6.526-3.072-9.342-.768-.128.128-.256.256-.512.384l-47.351 47.48Z" />
              <path fill="#FFF" d="M80.009 187.637c-.512.256-.768.768-.64 1.28l2.175 9.214c.512 1.28-.256 2.816-1.663 3.2-1.024.384-2.176 0-2.816-.768l-14.077-13.95 45.943-45.943 15.87.256 10.75 10.75c-2.56 2.175-18.045 17.149-55.542 35.961Z" />
              <path fill="#FF6C37" d="M78.985 202.61c-1.024 0-2.048-.383-2.688-1.151l-13.95-13.95c-.255-.256-.383-.512-.383-.896 0-.383.128-.64.384-.895l45.944-45.944c.256-.256.64-.384.895-.384l15.87.256c.383 0 .64.128.895.384l10.75 10.75c.256.256.384.64.384 1.024s-.128.64-.512.896l-.895.767c-13.566 11.902-31.995 23.804-54.902 35.194l2.175 9.086c.384 1.664-.384 3.456-1.92 4.352-.767.384-1.407.512-2.047.512Zm-14.078-15.997 13.182 13.054c.384.64 1.152.896 1.792.512.64-.384.896-1.152.512-1.792l-2.176-9.214c-.256-1.152.256-2.176 1.28-2.688 22.652-11.39 40.952-23.163 54.39-34.81l-9.47-9.47-14.718-.256-44.792 44.664Z" />
              <path fill="#FFF" d="m52.11 197.62 11.006-11.007 16.38 16.381-26.107-1.791c-1.151-.128-1.92-1.152-1.791-2.304 0-.512.128-1.024.512-1.28Z" />
              <path fill="#FF6C37" d="m79.497 204.146-26.236-1.791c-1.92-.128-3.199-1.792-3.071-3.712.128-.768.384-1.535 1.024-2.047L62.22 185.59a1.237 1.237 0 0 1 1.792 0l16.38 16.38c.385.385.512.897.257 1.408-.256.512-.64.768-1.152.768Zm-16.381-15.74-10.11 10.11c-.384.255-.384.895 0 1.151.127.128.255.256.511.256l22.652 1.536-13.053-13.054ZM104.452 146.557c-.768 0-1.28-.64-1.28-1.28 0-.384.128-.64.384-.896l12.414-12.414a1.237 1.237 0 0 1 1.792 0l8.062 8.063c.384.384.512.768.384 1.28-.128.384-.512.767-1.023.895l-20.477 4.352h-.256Zm12.414-11.902-8.446 8.446 13.821-2.943-5.375-5.503Z" />
              <path fill="#FFF" d="m124.8 140.926-14.077 3.071c-1.024.256-2.048-.384-2.303-1.408-.128-.64 0-1.28.511-1.791l7.807-7.807 8.063 7.935Z" />
              <path fill="#FF6C37" d="M110.467 145.277a3.168 3.168 0 0 1-3.2-3.2c0-.895.385-1.663.897-2.303l7.806-7.807a1.237 1.237 0 0 1 1.792 0l8.062 8.063c.384.384.512.768.384 1.28-.128.384-.512.767-1.023.895l-14.078 3.072h-.64Zm6.399-10.622-6.91 6.91c-.257.257-.257.512-.129.768s.384.384.768.384l11.774-2.56-5.503-5.502ZM203.25 64.907c-.256-.767-1.151-1.151-1.92-.895-.767.255-1.151 1.151-.895 1.92 0 .127.128.255.128.383.768 1.536.512 3.455-.512 4.863-.512.64-.384 1.536.128 2.048.64.512 1.536.384 2.048-.256 1.92-2.432 2.303-5.503 1.023-8.063Z" />
            </svg>} />
    </div>;
};

<PostmanCard collectionId="26126890-83751c95-b07f-49c3-a0ab-c69c7e5260e0" />

Using the object APIs, you can create and manage records and activities within HubSpot. The object APIs have the same basic functionality for all supported objects, so you can substitute the `objectTypeId` in the endpoints to work with different objects. For example, to create contacts, you'd make a `POST` request to `crm/v3/objects/0-1` and to create courses, the request would be to `crm/v3/objects/0-410`.

<Warning>
  Some objects have limited API functionality. For more details, click the link to an object's endpoints reference documentation in the table below. If an object listed doesn't have its own guide, you can refer to the [objects API](/apps/developer-platform/add-features/app-objects/overview#overview-of-app-objects) guide and substitute the `{objectTypeId}` in each endpoint to your desired object.
</Warning>

Expand the section below to view objects and their [object type ID](/guides/crm/understanding-the-crm#object-type-ids) values.

<Accordion title="Object type ID values">
  | Object                                                                               | Type ID |
  | ------------------------------------------------------------------------------------ | ------- |
  | Appointments                                                                         | `0-421` |
  | [Calls](/api-reference/legacy/crm/activities/calls/guide)                            | `0-48`  |
  | [Carts](/api-reference/legacy/crm/objects/carts/guide)                               | `0-142` |
  | [Communications](/api-reference/legacy/crm/objects/communications/guide)             | `0-18`  |
  | [Companies](/api-reference/legacy/crm/objects/companies/guide)                       | `0-2`   |
  | [Contacts](/api-reference/legacy/crm/objects/contacts/guide)                         | `0-1`   |
  | Courses                                                                              | `0-410` |
  | [Custom objects](/api-reference/legacy/crm/objects/custom-objects/guide)             | `2-XXX` |
  | [Deals](/api-reference/legacy/crm/objects/deals/guide)                               | `0-3`   |
  | [Discounts](/api-reference/legacy/crm/objects/discounts/guide)                       | `0-84`  |
  | [Emails](/api-reference/legacy/crm/activities/emails/guide)                          | `0-49`  |
  | [Feedback submissions](/api-reference/legacy/crm/objects/feedback-submissions/guide) | `0-19`  |
  | [Fees](/api-reference/legacy/crm/objects/fees/guide)                                 | `0-85`  |
  | [Goals](/api-reference/legacy/crm/objects/goals/guide)                               | `0-74`  |
  | [Invoices](/api-reference/legacy/crm/objects/invoices/guide)                         | `0-53`  |
  | [Leads](/api-reference/legacy/crm/objects/leads/guide)                               | `0-136` |
  | [Line items](/api-reference/legacy/crm/objects/line-items/guide)                     | `0-8`   |
  | Listings                                                                             | `0-420` |
  | [Marketing events](/api-reference/legacy/marketing/marketing-events/guide)           | `0-54`  |
  | [Meetings](/api-reference/legacy/crm/activities/meetings/guide)                      | `0-47`  |
  | [Notes](/api-reference/legacy/crm/activities/notes/guide)                            | `0-46`  |
  | [Orders](/api-reference/legacy/crm/objects/orders/guide)                             | `0-123` |
  | [Payments](/api-reference/legacy/crm/objects/commerce-payments/guide)                | `0-101` |
  | [Postal mail](/api-reference/legacy/crm/activities/postal-mail/guide)                | `0-116` |
  | [Products](/api-reference/legacy/crm/objects/products/guide)                         | `0-7`   |
  | [Projects](/guides/account/projects/guide)                                           | `0-970` |
  | [Quotes](/api-reference/legacy/crm/objects/quotes/guide)                             | `0-14`  |
  | Services                                                                             | `0-162` |
  | [Subscriptions](/api-reference/legacy/crm/objects/commerce-subscriptions/guide)      | `0-69`  |
  | [Tasks](/api-reference/legacy/crm/activities/tasks/guide)                            | `0-27`  |
  | [Taxes](/api-reference/legacy/crm/objects/taxes/guide)                               | `0-86`  |
  | [Tickets](/api-reference/legacy/crm/objects/tickets/guide)                           | `0-5`   |
  | [Users](/api-reference/legacy/crm/objects/users/guide)                               | `0-115` |
</Accordion>

In this article, learn the basics of how to use the object APIs.

<Warning>
  New objects (e.g., appointments, courses, listings, services) must be activated in the HubSpot account before you can manage their records via API. Learn how to check if they're activated via the [object library API](/api-reference/legacy/crm/objects/object-library/guide) and [how to activate them in HubSpot](https://knowledge.hubspot.com/data-management/data-model-templates#view-the-object-library).
</Warning>

## Retrieve records

You can retrieve records individually or in batches. You can use the objects API to [retrieve all records of an object](#Retrieve-all-records-or-specific-records-by-ID) or retrieve [specific records by unique identifier values](#Retrieve-all-records-or-specific-records-by-ID). To [retrieve records based on specific criteria](#Retrieve-records-based-on-criteria), use the CRM search API.

### Retrieve all records or specific records by ID

* To retrieve an individual record, make a `GET` request to `/crm/v3/objects/{objectTypeId}/{recordId}`.
* To request a list of all records for an object, make a `GET` request to `/crm/v3/objects/{objectTypeId}`.
* To retrieve a batch of specific records by record ID or a [custom unique identifier property](/api-reference/legacy/crm/properties/guide#create-unique-identifier-properties), make a `POST` request to `crm/v3/objects/{objectTypeId}/batch/read` and include the `id` values of records in the request body.

<Note>
  Although the batch endpoint only retrieves records, it requires the `POST` method because batch requests send up to 100 record IDs in the request body. Using the `POST` method avoids the URL length limits that are applied to `GET` requests.
</Note>

For these endpoints, you can include the following query parameters in the request URL:

| Parameter               | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `properties`            | A comma separated list of the properties to be returned in the response. If the requested record doesn't have a value for a property, it will not appear in the response.                                                                                                                                                                                                                                                                                                          |
| `propertiesWithHistory` | A comma separated list of the current and historical properties to be returned in the response. If the requested record doesn't have a value for a property, it will not appear in the response.                                                                                                                                                                                                                                                                                   |
| `associations`          | A comma-separated list of objects to retrieve associated IDs for. Any specified associations that don't exist will not be returned in the response. Learn more about the [associations API.](/api-reference/legacy/crm/associations/associate-records/guide) **Note**: this parameter is <u>not</u> supported in the batch read endpoint. Learn more about [batch reading associations with the associations API](/api-reference/legacy/crm/associations/associate-records/guide). |
| `idProperty`            | Indicates the unique identifier property used to identify records. You only need to use this parameter if retrieving by a [custom unique identifier property](/api-reference/legacy/crm/properties/guide#create-unique-identifier-properties).                                                                                                                                                                                                                                     |

For example, to retrieve a meeting with the meeting's text body and starting time, you'd make a `GET` request to `/crm/v3/objects/0-47/{meetingId}?properties=hs_meeting_body,hs_timestamp` and your response would look similar to the following:

```json theme={null}
{
  "id": "65059681027",
  "properties": {
    "hs_createdate": "2024-11-20T20:12:09.236Z",
    "hs_lastmodifieddate": "2024-11-20T20:12:10.610Z",
    "hs_meeting_body": "<div style=\"\" dir=\"auto\" data-top-level=\"true\"><p style=\"margin:0;\">New meeting</p></div>",
    "hs_object_id": "65059681027",
    "hs_timestamp": "2024-11-20T20:12:03.054Z"
  },
  "createdAt": "2024-11-20T20:12:09.236Z",
  "updatedAt": "2024-11-20T20:12:10.610Z",
  "archived": false
}
```

To retrieve a batch of deals, your request could look like either of the following:

```json theme={null}
{
  "properties": ["dealname", "dealstage", "pipeline"],
  "inputs": [
    {
      "id": "7891023"
    },
    {
      "id": "987654"
    }
  ]
}
```

```json theme={null}
{
  "properties": ["dealname", "dealstage", "pipeline"],
  "idProperty": "uniqueordernumber",
  "inputs": [
    {
      "id": "0001111"
    },
    {
      "id": "0001112"
    }
  ]
}
```

You can retrieve up to 100 records in a batch request.

* To retrieve a specific number of records under 100, add a value to the `limit` parameter. For example, you would use `?limit=50` to retrieve 50 records.
* To retrieve additional records in subsequent requests (i.e. the records after the limit was reached in your request), include the `after` parameter with the `after` value returned from the previous request. This value is the Record ID of the next record. For example, `?after=123456`.

For example, to retrieve 50 listings, your request URL would be `GET` `/crm/v3/objects/0-420?limit=50`. In your response, under the `paging` object below the list of returned listings, the `after` value is the `id` of the next listing that would’ve been returned. To request 50 more listings, starting with the next returned value, make a `GET` request to `/crm/v3/objects/0-420?limit=50&after={id}`.

The `after` field is highlighted in the example response below:

```json highlight={18} theme={null}
{
  "results": [
    {
      "id": "513881705057",
      "properties": {
        "hs_createdate": "2025-12-22T18:16:33.376Z",
        "hs_lastmodifieddate": "2025-12-22T18:16:33.376Z",
        "hs_object_id": "513881705057"
      },
      "createdAt": "2025-12-22T18:16:33.376Z",
      "updatedAt": "2025-12-22T18:16:33.376Z",
      "archived": false,
      "url": "https://app.hubspot.com/contacts/{HubId}/record/0-420/513881705057"
    }
  ],
  "paging": {
    "next": {
      "after": "513881705058",
      "link": "https://api.hubapi.com/crm/objects/v3/0-420?limit=1&after=513881705058"
    }
  }
}
```

### Retrieve records based on criteria

To include filters that retrieve records based on specific criteria, use the [CRM search API](/api-reference/legacy/crm/search-the-crm#filter-search-results). The `id` values of returned records can then be used to manage records via the objects API endpoints.

For example, to retrieve all deals in the *Presentation scheduled* stage with a value over \$10,000, you'd make a `POST` request to `/crm/v3/objects/deals/search`, and your request would look like the following:

```json theme={null}
{
    "filterGroups":[
      {
        "filters":[
          {
            "propertyName": "dealstage",
            "operator": "EQ",
            "value": "presentationscheduled"
          },
          {
            "propertyName": "amount",
            "operator": "GT",
            "value": "10000"
          }
        ]
      }
    ]
  }
```

## Create records

* To create a record for an object, make a `POST` request to `crm/v3/objects/{objectTypeId}`.
* To create multiple records, make a `POST` request to `/crm/v3/objects/{objectTypeId}/batch/create`.

In your request, include data for each record in a `properties` object. You can also add an `associations` object to associate your new record with existing records (e.g., companies, deals), or activities (e.g., meetings, notes).

<Info>
  If you want to create and update records at the same time, learn how to [upsert records](#upsert-records) below.
</Info>

### Properties

Record details are stored in properties. To view all available properties for an object, you can retrieve a list of your account's properties by making a `GET` request to `/crm/v3/properties/{objectTypeId}`. Learn more about the [properties API](/api-reference/legacy/crm/properties/guide) and [how to format property values.](/api-reference/legacy/crm/properties/guide#update-or-clear-a-property-s-values)

Expand the section below to view the objects for which records can be created via API, and the properties required for creation.

<Accordion title="Required properties to create records">
  | Object           | Type ID | Required properties to create                                                                                                                                                             |
  | ---------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | Appointments     | `0-421` | `hs_appointment_name`                                                                                                                                                                     |
  | Calls            | `0-48`  | `hs_timestamp`                                                                                                                                                                            |
  | Carts            | `0-142` | None, but recommended `hs_cart_name`                                                                                                                                                      |
  | Communications   | `0-18`  | `hs_timestamp` and `hs_communication_channel_type`                                                                                                                                        |
  | Companies        | `0-2`   | At least one of `domain` (recommended) or `name`                                                                                                                                          |
  | Contacts         | `0-1`   | None, but recommended at least one of `email`, `firstname`, or `lastname`                                                                                                                 |
  | Courses          | `0-410` | `hs_course_name`                                                                                                                                                                          |
  | Custom objects   | `2-XXX` | The [required properties](/api-reference/legacy/crm/objects/custom-objects/guide#properties) specified in your object's [schema](/api-reference/legacy/crm/objects/object-library/guide). |
  | Deals            | `0-3`   | `dealname`, `dealstage` and `pipeline`                                                                                                                                                    |
  | Emails           | `0-49`  | `hs_timestamp` and `hs_email_direction`                                                                                                                                                   |
  | Invoices         | `0-53`  | `hs_currency`                                                                                                                                                                             |
  | Leads            | `0-136` | `hs_associated_contact_email`, `hs_associated_contact_lastname`, `hs_lead_name`, `hs_associated_company_domain`, `hs_associated_contact_firstname`, and `hs_associated_company_name`      |
  | Line items       | `0-8`   | None, but review [recommended properties](/api-reference/legacy/crm/objects/line-items/guide).                                                                                            |
  | Listings         | `0-420` | `hs_name`                                                                                                                                                                                 |
  | Marketing events | `0-54`  | `hs_event_description` and `hs_event_name`                                                                                                                                                |
  | Meetings         | `0-47`  | `hs_timestamp`                                                                                                                                                                            |
  | Notes            | `0-46`  | `hs_timestamp`                                                                                                                                                                            |
  | Orders           | `0-123` | `hs_order_name`                                                                                                                                                                           |
  | Payments         | `0-101` | `hs_initial_amount` and `hs_initiated_date`                                                                                                                                               |
  | Postal mail      | `0-116` | `hs_timestamp`                                                                                                                                                                            |
  | Products         | `0-7`   | `hs_sku`, `hs_folder`, `price`, `name`, and `description`                                                                                                                                 |
  | Projects         | `0-970` | `hs_name`, `hs_pipeline`, and `hs_pipeline_stage`                                                                                                                                         |
  | Quotes           | `0-14`  | `hs_title` and `hs_expiration_date`                                                                                                                                                       |
  | Services         | `0-162` | `hs_name`, `hs_pipeline`, and `hs_pipeline_stage`                                                                                                                                         |
  | Subscriptions    | `0-69`  | `hs_name`                                                                                                                                                                                 |
  | Tasks            | `0-27`  | `hs_timestamp`                                                                                                                                                                            |
  | Tickets          | `0-5`   | `subject` (the ticket's name), `hs_pipeline_stage` (the ticket's status), and `hs_pipeline`                                                                                               |
  | Users            | `0-115` | `hs_internal_user_id` and `hs_email`                                                                                                                                                      |
</Accordion>

For example, to create a new ticket without associations, your request may look similar to the following:

```json theme={null}
{
  "properties": {
    "hs_pipeline": "0",
    "hs_pipeline_stage": "1",
    "hs_ticket_priority": "HIGH",
    "subject": "troubleshoot report"
  }
}
```

For example, to create multiple contacts without associations, your request may look similar to the following:

```json theme={null}
{
  "inputs": [
    {
      "properties": {
        "email": "testone@test.com",
        "firstname": "Test",
        "lastname": "PersonOne",
        "favorite_food": "Pizza"
      }
    },
    {
      "properties": {
        "email": "testtwo@test.com",
        "firstname": "Test",
        "lastname": "PersonTwo",
        "favorite_food": "Ice cream"
      }
    }
  ]
}
```

### Associations

When creating a new record, you can also associate it with [existing records](https://knowledge.hubspot.com/records/associate-records) or [activities](https://knowledge.hubspot.com/records/associate-activities-with-records) by including an `associations` object. In the `associations` object, you should include the following:

| Parameter | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `to`      | The record or activity you want to associate with the record, specified by its unique `id` value.                                                                                                                                                                                                                                                                                                                                                                             |
| `types`   | The type of the association between the record and the record/activity. Include the `associationCategory` and `associationTypeId`. Default association type IDs are listed [here](/api-reference/legacy/crm/associations/associate-records/guide#association-type-id-values), or you can retrieve the value for custom association types (i.e. labels) via the [associations API](/api-reference/legacy/crm/associations/associate-records/guide#retrieve-association-types). |

For example, to create a new contact and associate with an existing company and email, your request would look like the following:

```json theme={null}
{
  "properties": {
    "email": "example@hubspot.com",
    "firstname": "Jane",
    "lastname": "Doe",
    "phone": "(555) 555-5555",
    "company": "HubSpot",
    "website": "hubspot.com",
    "lifecyclestage": "marketingqualifiedlead"
  },
  "associations": [
    {
      "to": {
        "id": 123456
      },
      "types": [
        {
          "associationCategory": "HUBSPOT_DEFINED",
          "associationTypeId": 279
        }
      ]
    },
    {
      "to": {
        "id": 556677
      },
      "types": [
        {
          "associationCategory": "HUBSPOT_DEFINED",
          "associationTypeId": 197
        }
      ]
    }
  ]
}
```

For example, to create multiple deals and associate them with existing companies and meetings, your request would look similar to the following:

<Info>
  For batch create actions, you can enable multi-status errors which tell you which records were successfully created and which were not. Learn more about [setting up multi-status error handling](#multi-status-errors-for-batch-create-requests).
</Info>

```json theme={null}
{
  "inputs": [
    {
      "associations": [
        {
          "types": [
            {
              "associationCategory": "HUBSPOT_DEFINED",
              "associationTypeId": 5
            }
          ],
          "to": {
            "id": "23125848331"
          }
        },
        {
          "types": [
            {
              "associationCategory": "HUBSPOT_DEFINED",
              "associationTypeId": 211
            }
          ],
          "to": {
            "id": "65059681027"
          }
        }
      ],
      "properties": {
        "dealname": "New deal 1",
        "dealstage": "qualifiedtobuy",
        "pipeline": "default"
      }
    },
    {
      "associations": [
        {
          "types": [
            {
              "associationCategory": "HUBSPOT_DEFINED",
              "associationTypeId": 5
            }
          ],
          "to": {
            "id": "23125848331"
          }
        },
        {
          "types": [
            {
              "associationCategory": "HUBSPOT_DEFINED",
              "associationTypeId": 211
            }
          ],
          "to": {
            "id": "65059681027"
          }
        }
      ],
      "properties": {
        "dealname": "New deal 2",
        "dealstage": "qualifiedtobuy",
        "pipeline": "default"
      }
    }
  ]
}
```

## Update records

You can update records individually or in batches. For existing records, the Record ID is a default [unique value](/guides/crm/understanding-the-crm#unique-identifiers-and-record-ids) that you can use to update the record via API, but you can also identify records using the `idProperty` parameter with a [custom unique identifier property](/api-reference/legacy/crm/properties/guide#create-unique-identifier-properties). If you want to create and update records at the same time, learn how to [upsert records](#upsert-records).

* To update an individual record, make a `PATCH` request to `/crm/v3/objects/{objectTypeId}/{recordId}`, and include the data you want to update.
* To update multiple records, make a `POST` request to `/crm/v3/objects/{objectTypeId}/batch/update`. In the request body, include an array with the identifiers for the records and the properties you want to update.

<Warning>
  If you've [merged records](https://knowledge.hubspot.com/records/merge-records), you can use the previous record ID values stored in the `hs_merged_object_ids` field to update a record using the basic update endpoint. However, these values are not supported when updating records using the batch update endpoint.
</Warning>

For example, to update a contact, your request would look similar to the following:

```json theme={null}
{
  "properties": {
    "favorite_food": "burger",
    "jobtitle": "Manager",
    "lifecyclestage": "Customer"
  }
}
```

## Upsert records

You can also batch create and update records at the same time using the upsert endpoint. For this endpoint, you can use a [custom unique identifier property](/api-reference/legacy/crm/properties/guide#create-unique-identifier-properties) or `email` for contacts. Following the request, if the records already exist, they'll be updated and if the records don't exist, they'll be created.

To upsert records, make a `POST` request to `/crm/v3/objects/{objectTypeId}/batch/upsert`. In your request body, include the `idProperty` parameter to identify the unique identifier property you're using. Include that property's value as the `id` ​and add the other properties you want to set or update.

<Warning>
  Partial upserts are not supported when using `email` as the `idProperty` for contacts. To complete a partial upsert, use a custom unique identifier property as the `idProperty` instead.
</Warning>

For example, to upsert contacts to set the phone number property using `email` as the identifier, your request would look similar to the following:

```json theme={null}
{
  "inputs": [
    {
      "properties": {
        "phone": "5555555555"
      },
      "id": "luke@lukesdiner.com",
      "idProperty": "email"
    },
    {
      "properties": {
        "phone": "7777777777"
      },
      "id": "lorelai@thedragonfly.com",
      "idProperty": "email"
    },
    {
      "properties": {
        "phone": "1111111111"
      },
      "id": "michel@thedragonfly.com",
      "idProperty": "email"
    }
  ]
}
```

## Update associations

Once records are created, you can update their associations using the [associations API](/api-reference/legacy/crm/associations/associate-records/guide).

* To associate a record with other records or an activity, make a `PUT` request to `/crm/v3/objects/{objectTypeId}/{fromRecordId}/associations/{toObjectTypeId}/{toRecordId}/{associationTypeId}`.
* To remove an association between a record and a record or activity, make a `DELETE` request to the following URL: `/crm/v3/objects/{objectTypeId}/{fromRecordId}/associations/{toObjectTypeId}/{toRecordId}/{associationTypeId}`.

<Info>
  To retrieve the `associationTypeId` value, refer to [this list](/api-reference/legacy/crm/associations/associate-records/guide#association-type-id-values) of default values, or make a `GET` request to `/crm/v4/associations/{fromObjectTypeId}/{toObjectTypeId}/labels`.
</Info>

## Pin an activity on a record

You can [pin an activity](https://knowledge.hubspot.com/records/pin-an-activity-on-a-record) on a record by including the `hs_pinned_engagement_id` field in your create, update, or upsert request. In the field, include the `id` of the activity to pin, which can be retrieved by making a `GET` request to `/crm/v3/objects/{objectTypeId}/{recordId}` for calls, communications, emails, meetings, notes, postal mail, or tasks. You can pin one activity per record, and the activity must already be associated with the record prior to pinning.

For example, to set or update an existing deal's pinned activity, your request could look like:

```json theme={null}
{
  "properties": {
    "hs_pinned_engagement_id": 123456789
  }
}
```

To create a new deal, associate it with an activity, and pin that activity, you request would look like:

```json theme={null}
{
  "properties": {
    "dealname": "New Deal",
    "pipeline": "default",
    "dealstage": "appointmentscheduled",
    "hs_pinned_engagement_id": 123456789
  },
  "associations": [
    {
      "to": {
        "id": 123456789
      },
      "types": [
        {
          "associationCategory": "HUBSPOT_DEFINED",
          "associationTypeId": 205
        }
      ]
    }
  ]
}
```

## Delete records

You can delete records individually or in batches, which will add the record to the recycling bin in HubSpot. You can [restore the record within HubSpot](https://knowledge.hubspot.com/records/restore-deleted-records) for up to 90 days after deletion.

* To delete an individual record by its record ID, make a `DELETE` request to `/crm/v3/objects/{objectTypeId}/{recordId}`.
* To delete multiple records, make a `POST` request to `/crm/v3/objects/{objectTypeId}/batch/archive` and include the record ID values as the `id` inputs in your request body.

For example, to delete multiple appointments, your request would look like:

```json theme={null}
{
  "inputs": [
    {
      "id": "123456"
    },
    {
      "id": "7891011"
    },
    {
      "id": "12123434"
    }
  ]
}
```

## Limits

Object API batch endpoints are limited to 100 inputs per request. For example, create or retrieve up to 100 contacts per request.

## Error handling

The following are common errors you may encounter when using the object APIs. Refer to the [error handling guide](/api-reference/error-handling#common-error-responses) for details about more error responses and how to resolve them.

| Error                   | Details                                                                                                                                                                                                                                                  |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `207 Multi-Status`      | Returned when there are different statuses (e.g., errors and successes), which occurs when you've enabled [multi-status error handling](#multi-status-errors-for-batch-create-requests) for the object API batch create endpoints.                       |
| `400 Bad Request`       | Returned when your request includes invalid formatting or values. The error response will include details about why the error occurred.                                                                                                                  |
| `401 Unauthorized`      | Returned when the authentication provided is invalid. See the [authentication overview](/apps/developer-platform/build-apps/authentication/overview) for details on authenticating API requests.                                                         |
| `403 Forbidden`         | Returned when the authentication provided does not have the proper permissions to access the specific URL. See the [list of scopes](/apps/developer-platform/build-apps/authentication/scopes) to understand which scopes are required for your request. |
| `423 Locked`            | Returned when attempting to sync a large volume of data (e.g., upserting thousands of company records in a very short period of time). Include a delay of at least 2 seconds between your API requests.                                                  |
| `429 Too many requests` | Returned when your account or app is over its API [rate limits](/developer-tooling/platform/usage-guidelines).                                                                                                                                           |

For example:

* If you attempt to create a company with an invalid property name, your error response would look like:

```json title="400 Bad Request" theme={null}
{
  "status": "error",
  "message": "Property values were not valid: [{\"isValid\":false,\"message\":\"Property \\\"testproperty\\\" does not exist\",\"error\":\"PROPERTY_DOESNT_EXIST\",\"name\":\"testproperty\",\"localizedErrorMessage\":\"Property \\\"testproperty\\\" does not exist\",\"portalId\":{HubId}}]",
  "correlationId": "8a3f6c3a-8296-4002-b0a6-2a06fecf7c0c",
  "errors": [
    {
      "message": "Property \"testproperty\" does not exist",
      "code": "PROPERTY_DOESNT_EXIST",
      "context": {
        "propertyName": [
          "testproperty"
        ]
      }
    }
  ],
  "category": "VALIDATION_ERROR"
}
```

* If you attempt to retrieve deals without the `crm.objects.deals.read` scope, your response would look like:

```json title="403 Forbidden" theme={null}
{
  "status": "error",
  "message": "This app hasn't been granted all required scopes to make this call. Read more about required scopes here: https://developers.hubspot.com/scopes.",
  "correlationId": "dc49c0a8-9952-4937-aad4-e322b1e5cee0",
  "errors": [
    {
      "message": "One or more of the following scopes are required.",
      "context": {
        "requiredGranularScopes": [
          "crm.schemas.deals.read",
          "crm.objects.deals.sensitive.read.v2",
          "crm.objects.deals.read",
          "crm.objects.deals.highly_sensitive.read.v2"
        ]
      }
    }
  ],
  "links": {
    "scopes": "https://developers.hubspot.com/scopes"
  },
  "category": "MISSING_SCOPES"
}
```

### Multi-status errors for batch create requests

For the object APIs' batch create endpoints, you can enable multi-status responses that include partial failures by including a unique `objectWriteTraceId` value for each input in your request. The `objectWriteTraceId` can be any unique string that helps you identify which records succeeded or failed.

For example, a request to create tickets could look like:

```json highlight={4, 10} theme={null}
{
    "inputs": [
        {
            "objectWriteTraceId": "549b1c2a9350",
            "properties": {
                "hs_pipeline_stage": "1"
            }
        },
        {
            "objectWriteTraceId": "549b1c2a9351",
            "properties": {
                "missing": "1"
            }
        }
    ]
}
```

In the response, statuses are grouped so you can see which creates were successful and which failed. For the above request, your response would look like:

```json wrap theme={null}
{
  "status": "COMPLETE",
  "results": [
    {
      "id": "1145814089",
      "properties": {
        "createdate": "2024-08-15T17:09:13.648Z",
        "hs_helpdesk_sort_timestamp": "2024-08-15T17:09:13.648Z",
        "hs_last_message_from_visitor": "false",
        "hs_lastmodifieddate": "2024-08-15T17:09:13.648Z",
        "hs_object_id": "1145814089",
        "hs_object_source": "API",
        "hs_object_source_label": "INTERNAL_PROCESSING",
        "hs_pipeline": "0",
        "hs_pipeline_stage": "1",
        "hs_ticket_id": "1145814089"
      },
      "createdAt": "2024-08-15T17:09:13.648Z",
      "updatedAt": "2024-08-15T17:09:13.648Z",
      "archived": false
    }
  ],
  "numErrors": 1,
  "errors": [
    {
      "status": "error",
      "category": "VALIDATION_ERROR",
      "message": "Property values were not valid: [{\"isValid\":false,\"message\":\"Property \\\"missing\\\" does not exist\",\"error\":\"PROPERTY_DOESNT_EXIST\",\"name\":\"missing\",\"localizedErrorMessage\":\"Property \\\"missing\\\" does not exist\",\"portalId\":891936587}]",
      "context": {
        "objectWriteTraceId": ["549b1c2a9351"]
      }
    }
  ],
  "startedAt": "2024-08-15T17:09:13.610Z",
  "completedAt": "2024-08-15T17:09:13.910Z"
}
```
