Supported products
Supported products
Required Scopes
Required Scopes
Retrieve custom object records
You can retrieve custom object records individually or in batches. Use the objects API to retrieve all custom object records or retrieve specific custom object records by unique identifier values. To retrieve custom object records based on specific criteria, use the CRM search API.Retrieve all custom object records or specific records by ID
- To retrieve an individual custom object record, make a
GETrequest to/crm/v3/objects/{objectTypeId}/{recordId}. - To request a list of all a custom object’s records, make a
GETrequest to/crm/v3/objects/{objectTypeId}. - To retrieve a batch of specific custom object records by record ID or a custom unique identifier property, make a
POSTrequest to/crm/v3/objects/{objectTypeId}/batch/readand include theidvalues of records in the request body.
| 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 and defining associations for custom objects with the schemas 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. |
objectTypeId= 2-3465404), to retrieve a car record with the owner’s name, make a GET request to /crm/v3/objects/2-3465404/{carId}?properties=owner 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/2-3465404?limit=50. In your response, under the paging object below the list of returned cars, the after value is the id of the next car that would’ve been returned. To request 50 more cars, starting with the next returned value, make a GET request to /crm/v3/objects/2-3465404?limit=50&after={id}.
The after field is highlighted in the example response below:
Retrieve custom object records based on criteria
To include filters that retrieve custom object 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 2026 cars with a listing price over $50,000, you’d make a POST request to /crm/v3/objects/2-3465404/search, and your request would look like the following:
Create custom object records
- To create a record for a custom object, make a
POSTrequest to/crm/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 a custom object, you can retrieve a list of your account’s properties by making aGET request to /crm/v3/properties/{objectTypeId}. The required properties for a custom object are specified in the object’s schema.
Learn more about the properties API and how to format property values.
For example, to create a new car record without associations, your request may look similar to the following:
Associations
When creating a new custom object record, you can also associate it with existing records or activities by including anassociations object. For custom objects, you must define the association type with the desired object before associating their records.
In the associations object, include the following:
| Parameter | Description |
|---|---|
to | The record or activity you want to associate with the custom object record, specified by its unique id value. |
types | The type of the association between the custom object record and the record/activity. Include the associationCategory and associationTypeId. Retrieve the value for the custom object’s association types 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 custom object records
You can update custom object 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 custom object record, make a
PATCHrequest to/crm/v3/objects/{objectTypeId}/{recordId}, and include the data you want to update. - To update multiple custom object 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 custom object records at the same time using the upsert endpoint. For this endpoint, you can use a custom unique identifier property. 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 aPOST 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 cars to set the price property using VIN as the identifier, your request would look similar to the following:
Update custom object record associations
Once custom object records are created, you can update their associations using the associations API. For custom objects, you must define the association type with the desired object before you can associate their records.- To associate a custom object 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 custom object 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 values, make a GET request to /crm/v4/associations/{fromObjectTypeId}/{toObjectTypeId}/labels.Pin an activity on a custom object record
You can pin an activity on a custom object 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 car’s pinned activity, your request could look like:
Delete custom object records
You can delete custom object 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 custom object record by its record ID, make a
DELETErequest to/crm/v3/objects/{objectTypeId}/{recordId}. - To delete multiple custom object records, make a
POSTrequest to/crm/v3/objects/{objectTypeId}/batch/archiveand include the record ID values as theidinputs in your request body.