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.
Expand the section below to view objects and their object type ID values.
Object type ID values
Object type ID values
| Object | Type ID |
|---|---|
| Appointments | 0-421 |
| Calls | 0-48 |
| Carts | 0-142 |
| Communications | 0-18 |
| Companies | 0-2 |
| Contacts | 0-1 |
| Courses | 0-410 |
| Custom objects | 2-XXX |
| Deals | 0-3 |
| Discounts | 0-84 |
| Emails | 0-49 |
| Feedback submissions | 0-19 |
| Fees | 0-85 |
| Goals | 0-74 |
| Invoices | 0-53 |
| Leads | 0-136 |
| Line items | 0-8 |
| Listings | 0-420 |
| Marketing events | 0-54 |
| Meetings | 0-47 |
| Notes | 0-46 |
| Orders | 0-123 |
| Payments | 0-101 |
| Postal mail | 0-116 |
| Products | 0-7 |
| Projects | 0-970 |
| Quotes | 0-14 |
| Services | 0-162 |
| Subscriptions | 0-69 |
| Tasks | 0-27 |
| Taxes | 0-86 |
| Tickets | 0-5 |
| Users | 0-115 |
Retrieve records
You can retrieve records individually or in batches. You can use the objects API to retrieve all records of an object or retrieve specific records by unique identifier values. To retrieve records based on specific criteria, use the CRM search API.Retrieve all records or specific records by ID
- To retrieve an individual record, make a
GETrequest to/crm/v3/objects/{objectTypeId}/{recordId}. - To request a list of all records for an object, make a
GETrequest to/crm/v3/objects/{objectTypeId}. - To retrieve a batch of specific records by record ID or a custom unique identifier property, make a
POSTrequest tocrm/v3/objects/{objectTypeId}/batch/readand include theidvalues of records in the request body.
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.| 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. Note: this parameter is not supported in the batch read endpoint. Learn more about batch reading associations with the associations API. |
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. |
GET request to /crm/v3/objects/0-47/{meetingId}?properties=hs_meeting_body,hs_timestamp and your response would look similar to the following:
- To retrieve a specific number of records under 100, add a value to the
limitparameter. For example, you would use?limit=50to retrieve 50 records. - To retrieve additional records in subsequent requests (i.e. the records after the limit was reached in your request), include the
afterparameter with theaftervalue returned from the previous request. This value is the Record ID of the next record. For example,?after=123456.
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:
Retrieve records based on criteria
To include filters that retrieve records based on specific criteria, use the CRM search API. Theid 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:
Create records
- To create a record for an object, make a
POSTrequest tocrm/v3/objects/{objectTypeId}. - To create multiple records, make a
POSTrequest to/crm/v3/objects/{objectTypeId}/batch/create.
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).
If you want to create and update records at the same time, learn how to upsert records below.
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 aGET request to /crm/v3/properties/{objectTypeId}. Learn more about the properties API and how to format property values.
Expand the section below to view the objects for which records can be created via API, and the properties required for creation.
Required properties to create records
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 specified in your object’s schema. |
| 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. |
| 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 |
Associations
When creating a new record, you can also associate it with existing records or activities by including anassociations 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, or you can retrieve the value for custom association types (i.e. labels) via the associations API. |
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.
Update records
You can update records individually or in batches. For existing records, the Record ID is a default unique value that you can use to update the record via API, but you can also identify records using theidProperty parameter with a custom unique identifier property. If you want to create and update records at the same time, learn how to upsert records.
- To update an individual record, make a
PATCHrequest to/crm/v3/objects/{objectTypeId}/{recordId}, and include the data you want to update. - To update multiple records, make a
POSTrequest 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.
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 oremail 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.
For example, to upsert contacts to set the phone number property using email as the identifier, your request would look similar to the following:
Update associations
Once records are created, you can update their associations using the associations API.- To associate a record with other records or an activity, make a
PUTrequest to/crm/v3/objects/{objectTypeId}/{fromRecordId}/associations/{toObjectTypeId}/{toRecordId}/{associationTypeId}. - To remove an association between a record and a record or activity, make a
DELETErequest to the following URL:/crm/v3/objects/{objectTypeId}/{fromRecordId}/associations/{toObjectTypeId}/{toRecordId}/{associationTypeId}.
To retrieve the
associationTypeId value, refer to this list of default values, or make a GET request to /crm/v4/associations/{fromObjectTypeId}/{toObjectTypeId}/labels.Pin an activity on a record
You can pin an activity on a record by including thehs_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:
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 for up to 90 days after deletion.- To delete an individual record by its record ID, make a
DELETErequest to/crm/v3/objects/{objectTypeId}/{recordId}. - To delete multiple records, make a
POSTrequest to/crm/v3/objects/{objectTypeId}/batch/archiveand include the record ID values as theidinputs in your request body.
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 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 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 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 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. |
- If you attempt to create a company with an invalid property name, your error response would look like:
400 Bad Request
- If you attempt to retrieve deals without the
crm.objects.deals.readscope, your response would look like:
403 Forbidden
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 uniqueobjectWriteTraceId 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: