# Search in v3 API using the externalObjectId value that was set via v2 api using e-commerce sync mess

**URL:** <https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360>\
**Category:** APIs & Integrations\
**Tags:** professional, starter\
**Created:** [March 2, 2023, 2:47pm UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360 "2023-03-02T14:47:51Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![DOpanovich](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@DOpanovich](https://community.hubspot.com/u/DOpanovich)\
**Post date:** [March 2, 2023, 2:47pm UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/1 "2023-03-02T14:47:51Z")

</div>

> * * *

 ![DOpanovich_0-1677155254230.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/9/799f6df84d98f7776f484eb83dfc274a87ad6631.png)

> **[Accounts Dashboard | HubSpot](https://app.hubspot.com/myaccounts?next=developerdocs&redirect=%2Fapi-reference%2Fdeprecated)**

As I understand it, previously we could create contacts, deals and other records using

**PUT /extensions/ecomm/v2/sync/messages**

Where you can use **externalObjectId = objectId from my system**

And now this api is obsolete.

So, we need to use api v3, for example this request to update deals,

**PATCH** /crm/v3/objects/deals/{dealId}

And the main question is:

Can I find old records that were created by

**PUT /extensions/ecomm/v2/sync/messages**

using the value stored in **externalObjectId**?

Example:

Previously, we created a contact record in HubSpot using:

**PUT /extensions/ecomm/v2/sync/messages** with “ **externalObjectId** ”: “ **1234** ”,

and in my database the contact has **id=1234**

```lia-code-sample
{
 "storeId": "example-store-id",
 "objectType": "CONTACT",
 "messages": [
 {
 "action": "UPSERT",
 "changedAt": "1553486400000",
 "externalObjectId": "1234",
 "properties": {
 "firstname": "Jeff",
 "lastname": "David",
 "email": "test@example.com"
 },
 "associations": {
 "DEAL": [
 "example_dealId"
 ]
 }
 }
 ]
}

```

Is it possible to find this entry using only ID=1234 and using the v3 API?

(prev topic is [https://community.hubspot.com/t5/APIs-Integrations/Search-in-v3-API-using-externalObjectId/m-p/760016#M61625](https://community.hubspot.com/t5/APIs-Integrations/Search-in-v3-API-using-externalObjectId/m-p/760016#M61625))

---

<div class="post-metadata">

**Author:** ![DOpanovich](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@DOpanovich](https://community.hubspot.com/u/DOpanovich)\
**Post date:** [February 23, 2023, 9:53am UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/2 "2023-02-23T09:53:22Z")

</div>

Hi, is it possible to use **externalObjectId** to search in **v3 API**?  
For example, we previously used this query  
**[https://api.hubapi.com/extensions/ecomm/v2/sync/messages](https://api.hubapi.com/extensions/ecomm/v2/sync/messages)**

with this body (example for product):

**{**

```
**action: action,**

**externalObjectId: obj.id,**

   **properties: {**

      **price: obj.price \|\| 0,**

      **name: obj.name \|\| '',**

      **description: obj.description \|\| '',**

      **hs\_sku: obj.sku \|\| '',**

   **}

```

}\*\*

Or maybe we need to use a different way to match old and new data?

Thanks for help!

---

<div class="post-metadata">

**Author:** ![enrico\_baskey](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/enrico_baskey/32/98852_2.png) [@enrico\_baskey](https://community.hubspot.com/u/enrico_baskey)\
**Post date:** [February 23, 2023, 10:33am UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/3 "2023-02-23T10:33:18Z")

</div>

Hello,

the V3 Search API is really powerfull. You can filter the search result for any property.

Check out the documentation page for more information: [Search the CRM - HubSpot docs](https://developers.hubspot.com/docs/api/crm/search)

You basically POST to `/crm/v3/objects/\<YOUR_OBJECT_TYPE_HERE\>/search`, and in the post body, you can then apply your filters. Taken the example from the documentation for searching a contact, the request would look like this:

```lia-code-sample
POST https://api.hubapi.com/crm/v3/objects/contacts/search
Authorization: Bearer {{apiToken}}
Content-Type: application/json

{
 "filterGroups":[
 {
 "filters":[
 {
 "propertyName": "firstname",
 "operator": "EQ",
 "value": "Alice"
 }
 ]
 }
 ]
}

```

---

<div class="post-metadata">

**Author:** ![DOpanovich](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@DOpanovich](https://community.hubspot.com/u/DOpanovich)\
**Post date:** [February 23, 2023, 10:37am UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/4 "2023-02-23T10:37:35Z")

</div>

Thanks for your reply, yes, I understand that I can use name etc.

But can I use **externalObjectId** for this purpose?

For example, I have two products with the same name, but only the **externalObjectId** is different.  
And as I understand it, this code will not work

```lia-code-sample
{
 "filterGroups":[
 {
 "filters":[
 {
 "propertyName": "externalObjectId",
 "operator": "EQ",
 "value": "1010101"
 }
 ]
 }
 ]
}

```

---

<div class="post-metadata">

**Author:** ![enrico\_baskey](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/enrico_baskey/32/98852_2.png) [@enrico\_baskey](https://community.hubspot.com/u/enrico_baskey)\
**Post date:** [February 23, 2023, 10:56am UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/5 "2023-02-23T10:56:31Z")

</div>

Do you mean line-items instead of products?

In my understanding a line-items “externalObjectId” refers to the products “hs\_object\_id”. You can search products for “hs\_object\_id” and use your “externalObjectId” as object id.  
So maybe try:

```lia-code-sample
{
 "filterGroups":[
 {
 "filters":[
 {
 "propertyName": "hs_object_id",
 "operator": "EQ",
 "value": "1010101"
 }
 ]
 }
 ]
}

```

---

<div class="post-metadata">

**Author:** ![DOpanovich](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@DOpanovich](https://community.hubspot.com/u/DOpanovich)\
**Post date:** [February 23, 2023, 11:08am UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/6 "2023-02-23T11:08:29Z")

</div>

Hmm, to clarify.

The **hs\_object\_id** in deals, line\_items, products, contacts are equal to **externalObjectId** form this request?

**{**

```
**action: action,**

**externalObjectId: obj.id,**

   **properties: {**

   **price: obj.price \|\| 0,**

   **name: obj.name \|\| '',**

   **description: obj.description \|\| '',**

   **hs\_sku: obj.sku \|\| '',**

**}**

```

**}**

Since this field is currently read-only, it equals id

**{**  
**“id”: “17501”,**  
**“properties”: {**  
**“company”: “Biglytics”,**  
**“createdate”: “2023-02-23T11:00:45.448Z”,**  
**“email”: “[bcooper@biglytics.net](mailto:bcooper@biglytics.net)”,**  
**“firstname”: “Bryan”,**  
**“hs\_all\_contact\_vids”: “17501”,**  
**…**  
**“hs\_object\_id”: “17501”,**  
**“hs\_pipeline”: “contacts-lifecycle-pipeline”,**  
**“hs\_searchable\_calculated\_phone\_number”: “8779290687”,**  
**…**  
**“website”: “[http://biglytics.net](http://biglytics.net)”**  
**},**  
**“createdAt”: “2023-02-23T11:00:45.448Z”,**  
**“updatedAt”: “2023-02-23T11:00:45.448Z”,**  
**“archived”: false**  
**}**

---

<div class="post-metadata">

**Author:** ![enrico\_baskey](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/enrico_baskey/32/98852_2.png) [@enrico\_baskey](https://community.hubspot.com/u/enrico_baskey)\
**Post date:** [February 23, 2023, 11:58am UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/7 "2023-02-23T11:58:56Z")

</div>

The request you posted isn’t for searching, is it?

May i ask what are you trying to do?  
Do you want to get the object that is referenced by the **externalObjectId** , or do you want to get all records, which has the same **externalObjectId**?

But generally speaking, yes.

**externalObjectId** seems to refer to an external object.  
And you can use this **externalObjectId** to get this specific resource if you use this as **hs\_object\_id** and get the referenced object.  
So for example, if i create a line-item, it references to a product. So the line-items ~~**externalObjectId**~~ [edit: **hs\_product\_id**] is the products **hs\_object\_id**. Keep in mind that there could be several line-items referencing to the same product.

But in my understanding, there is no **externalObjectId** ,so in case of product-line-item, the property would be **hs\_product\_id.**

---

<div class="post-metadata">

**Author:** ![DOpanovich](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@DOpanovich](https://community.hubspot.com/u/DOpanovich)\
**Post date:** [February 23, 2023, 12:14pm UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/8 "2023-02-23T12:14:50Z")

</div>

I’m trying to find records that were created in the old api via **[https://api.hubapi.com/extensions/ecomm/v2/sync/messages](https://api.hubapi.com/extensions/ecomm/v2/sync/messages)**  
and we used **externalObjectId = recordId** in our system

For example **externalObjectId = order.id**

And now we’re moving to the v3 api, and I need to match records.

And the only source of truth that I can use for a 100% guarantee is **externalObjectId** , because we passed it equal to the record id in our system.

And just to clarify, before, when we used **extensions/ecomm/v2/sync/messages** , when we sent something like this

```lia-code-sample
{
 "storeId": "example-store-id",
 "objectType": "CONTACT",
 "messages": [
 {
 "action": "UPSERT",
 "changedAt": "1553486400000",
 "externalObjectId": "1234",
 "properties": {
 "firstname": "Jeff",
 "lastname": "David",
 "email": "test@example.com"
 },
 "associations": {
 "DEAL": [
 "example_dealId"
 ]
 }
 }
 ]
}

```

in this case, Hubspot set **hs\_object\_id = externalObjectId**

And I can use this query to find, for example, all the transactions that we have in both systems.

```lia-code-sample
{
 "filterGroups":[
 {
 "filters":[
 {
 "propertyName": "hs_object_id",
 "operator": "IN",
 "values": [id1, id2, ...]
 }
 ]
 }
 ]
}

```

---

<div class="post-metadata">

**Author:** ![enrico\_baskey](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/enrico_baskey/32/98852_2.png) [@enrico\_baskey](https://community.hubspot.com/u/enrico_baskey)\
**Post date:** [February 23, 2023, 12:23pm UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/9 "2023-02-23T12:23:24Z")

</div>

So you have **externalObjectId** as a custom property, and want to find a record with this property set to a specific value?

Then your proposed request should work just fine:

```lia-code-sample
POST https://api.hubapi.com/crm/v3/objects/{{objectType}}/search
Authorization: Bearer {{apiToken}}
Content-Type: application/json

{
 "properties": ["externalObjectId"],
 "filterGroups":[
 {
 "filters":[
 {
 "propertyName": "externalObjectId",
 "operator": "EQ",
 "value": "{{externalObjectId}}"
 }
 ]
 }
 ]
}

```

---

<div class="post-metadata">

**Author:** ![DOpanovich](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@DOpanovich](https://community.hubspot.com/u/DOpanovich)\
**Post date:** [February 23, 2023, 12:40pm UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/10 "2023-02-23T12:40:25Z")

</div>

> * * *
> 
> [@enrico\_baskey](https://community.hubspot.com/t5/user/viewprofilepage/user-id/526222) wrote:
> 
> So you have **externalObjectId** as a custom property, and want to find a record with this property set to a specific value?
> 
> * * *

No, this property is from Hubspot.

 ![DOpanovich_0-1677155254230.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/9/799f6df84d98f7776f484eb83dfc274a87ad6631.png)

> **[Accounts Dashboard | HubSpot](https://app.hubspot.com/myaccounts?next=developerdocs&redirect=%2Fapi-reference%2Fdeprecated)**

As I understand it, previously we could create contacts, deals and other records using

**PUT /extensions/ecomm/v2/sync/messages**

Where you can use **externalObjectId = objectId from my system**

And now this api is obsolete.

So, we need to use api v3, for example this request to update deals,

**PATCH** /crm/v3/objects/deals/{dealId}

And the main question is:

Can I find old records that were created by

**PUT /extensions/ecomm/v2/sync/messages**

using the value stored in **externalObjectId**?

Example:

Previously, we created a contact record in HubSpot using:

**PUT /extensions/ecomm/v2/sync/messages** with “ **externalObjectId** ”: “ **1234** ”,

and in my database the contact has **id=1234**

```lia-code-sample
{
 "storeId": "example-store-id",
 "objectType": "CONTACT",
 "messages": [
 {
 "action": "UPSERT",
 "changedAt": "1553486400000",
 "externalObjectId": "1234",
 "properties": {
 "firstname": "Jeff",
 "lastname": "David",
 "email": "test@example.com"
 },
 "associations": {
 "DEAL": [
 "example_dealId"
 ]
 }
 }
 ]
}

```

Is it possible to find this entry using only ID=1234 and using the v3 API?

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [March 7, 2023, 7:52am UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/11 "2023-03-07T07:52:10Z")

</div>

Hello @DOpanovich  
Hope for the best! Try this to find the record you created using the v2 API with the externalObjectId value of “1234” using the v3 API.

use the following endpoint to search for contacts based on their external ID:

GET /crm/v3/objects/contacts/search include a query parameter in the URL that specifies the external ID you are searching for, like this:

GET /crm/v3/objects/contacts/search?query=1234

This will return a list of all contacts that have an external ID of “1234”. If your contact was created using the v2 API with this external ID, it should appear in the results.

Keep in mind that the v3 API uses a different object model than the v2 API, so the properties and associations of your record might be stored differently in the v3 API. You will need to check the documentation for the v3 API to see how to access and update these values. If this works please let me know

---

<div class="post-metadata">

**Author:** ![DOpanovich](https://avatars.discourse-cdn.com/v4/letter/d/8491ac/32.png) [@DOpanovich](https://community.hubspot.com/u/DOpanovich)\
**Post date:** [March 7, 2023, 11:09am UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/12 "2023-03-07T11:09:08Z")

</div>

Thanks for the reply.

But v3 api search requires body params and also works throw POST request.

and according to the documents, I’m not sure it will search by externalObjectId

 ![DOpanovich_0-1678187291240.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/f/6/f6c0b6d5315d8d72534f8c382d8a78431e54aa1b.png)

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [March 9, 2023, 7:01am UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/13 "2023-03-09T07:01:35Z")

</div>

you can check for any alternate way for mapping your data. You can use the email property for contacts and the SKU property for products and other object fields likewise.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [March 3, 2023, 5:58pm UTC](https://community.hubspot.com/t/search-in-v3-api-using-the-externalobjectid-value-that-was-set-via-v2-api-using-e-commerce-sync-mess/76360/14 "2023-03-03T17:58:30Z")

</div>

Hi, @DOpanovich. Thanks for reaching out. I’m going to merge your previous post into this one to help keep things tidy.

Hey, @himanshurauthan has your team handled anything similar in the past?

Thank you! — Jaycee
