Scope requirements
Scope requirements
Retrieve a record image
To retrieve the image for a single record, make aGET request to /crm/record-images/2027-03-beta/{objectTypeId}/{objectId}. Include the object type’s ID and the record’s ID in the path.
For example, to retrieve the image for the contact with the record ID 51, make a GET request to /crm/record-images/2027-03-beta/0-1/51.
The response includes a signed URL for the image and the time that the URL expires.
The request can return the following error statuses:
Retrieve a batch of record images
To retrieve images for multiple records of the same object, make aPOST request to /crm/record-images/2027-03-beta/{objectTypeId}/batch/read. You can include up to 100 records per request.
By default, the
id values in the request are record IDs (hs_object_id). To look up contact records by email or company records by domain, include the field idProperty and set it to email (contacts) or domain (companies).
For example, the following request retrieves images for two contacts by email address:
results array and an errors array. Each result echoes the value you sent as its id. Both arrays are always present in the response.
Batch read returns the following status codes:
The following error categories can appear in
errors:
In the following example, one contact was found and one wasn’t:
Set a custom record image
To set a custom image for a record, make aPUT request to /crm/record-images/2027-03-beta/{objectTypeId}/{objectId}. You can set custom images on contacts, companies, custom object records, products, and marketing events.
Send the image as a file upload, using the multipart/form-data content type with the image in a file form parameter. HubSpot resizes the image if needed, stores it as a hidden file, and saves the file’s File Manager key to the record’s hs_avatar_filemanager_key property. The file doesn’t appear in the HubSpot files tool, but anyone with the image’s URL can view it.
The new image is displayed in place of any previous custom image, enriched image, or default image.
The following example uploads an image for the contact with the record ID 51:
id, and the file’s creation timestamp.
The request can return the following errors:
Clear a custom record image
To clear a record’s custom image, make aDELETE request to /crm/record-images/2027-03-beta/{objectTypeId}/{objectId}.
For example, to clear the custom image for the contact with the record ID 51, make a DELETE request to /crm/record-images/2027-03-beta/0-1/51.
A successful request returns a 204 No Content response. The record then displays the image it would have without a custom image, such as an enriched image or the default image. Learn more about how images resolve.
The uploaded file isn’t deleted from the File Manager. HubSpot sets the record’s hs_avatar_filemanager_key property to an empty value, and the record’s property history keeps the previous values.
The request can return the following errors:
Signed URLs
Every URL returned by this API is a signed URL that expires after one day. Each response includes anexpiresAt timestamp next to the url. It’s recommended to request a new URL when you need to display the image. Don’t store, email, or embed signed URLs in web pages. If you need to keep the image, download it.
- Expired URLs: a request to an expired URL returns a
410 Goneerror. Fetch a new URL from the API. - Invalid URLs: a tampered or malformed URL returns a
400error. - Data included in signed URLs: URLs are signed by record ID, even when you look up a record by email address or domain. A URL’s contents can be decoded and include the account ID, object type, record ID, issue time, expiry time, and image size. It doesn’t include an email address, domain, user ID, or IP address.
How record images resolve
A record’s image comes from the first of the following sources that exist:- Custom image: an image you’ve set on the record, either in HubSpot or through this API. The image’s File Manager key is stored in the record’s
hs_avatar_filemanager_keyproperty. - Enriched image: an image HubSpot found through data enrichment (contacts and companies only).
- Default image: HubSpot’s default image for the object type.
- Contacts (retrieved by
hs_object_idoremail): a contact’s custom image is used first. If the contact has none, HubSpot checks the contact’s email, then each parent domain (for example,eu.acme.com, thenacme.com). At each level, HubSpot uses the logo of a company on that domain that the caller can view, or else the domain’s enriched image. If none exist, the default image is used. - Companies:
- Retrieved by
hs_object_id: a company’s custom image is used first. If the company has none, it shows the enriched image for its domain, then for its parent domains, and then the default image. - Retrieved by
domain: companies can share a domain, so HubSpot returns one of them. It uses the first company on the parent domain that has its own logo and that the caller can view. If no company the caller can view is on the exact domain, HubSpot uses the nearest parent domain that has an image. For example,eu.acme.comwith no company of its own returns the company onacme.com, including its custom logo. Within a domain, a company with its own logo wins, otherwise the first company is returned. AnOBJECT_NOT_FOUNDerror applies when no viewable company exists on the domain or any of its parents.
- Retrieved by
Authentication and permissions
Scopes
Each endpoint requires both a record images scope and the CRM scope for the object type in the request path. A request that’s missing either scope returns a403 error.
Permissions
All record images endpoints accept both account-level (private app or service) tokens and user-level tokens. Account-level tokens can access all records in the account that the token’s scopes allow. When you use a user-level token, the user’s record permissions apply:- If the user can’t view a record, the API treats the record as not found. Requests return a
404error, and batch read returns anOBJECT_NOT_FOUNDerror for that record. - If the user can view a record but can’t edit it,
PUTandDELETErequests return a403error.