# 3rd party integration - how to create fine-grained scope?

**URL:** <https://community.hubspot.com/t/3rd-party-integration-how-to-create-fine-grained-scope/52784>\
**Category:** APIs & Integrations\
**Tags:** developer-tools, oauth, contacts\
**Created:** [March 9, 2022, 4:56am UTC](https://community.hubspot.com/t/3rd-party-integration-how-to-create-fine-grained-scope/52784 "2022-03-09T04:56:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeffZ1](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@JeffZ1](https://community.hubspot.com/u/JeffZ1)\
**Post date:** [March 9, 2022, 4:56am UTC](https://community.hubspot.com/t/3rd-party-integration-how-to-create-fine-grained-scope/52784/1 "2022-03-09T04:56:38Z")

</div>

Hi everyone,

I need to allow a lead generation company to call the Hubspot API to send leads to my company’s hubspot CONTACTS database directly. Is OAuth preferred over API key in this case?

My concern is that how do I prevent the 3rd party from accidently deleting or modifying our current contacts? What happens if a contact’s email already exists in our current CRM contacts? How should I define the scope in this case?

Thanks

Jeff

---

<div class="post-metadata">

**Author:** ![mangelet](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mangelet/32/83031_2.png) [@mangelet](https://community.hubspot.com/u/mangelet)\
**Post date:** [March 9, 2022, 9:04am UTC](https://community.hubspot.com/t/3rd-party-integration-how-to-create-fine-grained-scope/52784/2 "2022-03-09T09:04:53Z")

</div>

@JeffZ1

Consider creating a **serverless function** as a proxy to your HubSpot portal.

Benefits

- You don’t need to share your API key with them

- You can check for existing contacts before updating your database

---

<div class="post-metadata">

**Author:** ![JeffZ1](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@JeffZ1](https://community.hubspot.com/u/JeffZ1)\
**Post date:** [March 11, 2022, 4:30am UTC](https://community.hubspot.com/t/3rd-party-integration-how-to-create-fine-grained-scope/52784/3 "2022-03-11T04:30:36Z")

</div>

Thanks Martin! I appreciate your answer.

Just want to clarify… By serverless function, do you mean using something like AWS API Gateway + Lambda?

---

<div class="post-metadata">

**Author:** ![mangelet](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mangelet/32/83031_2.png) [@mangelet](https://community.hubspot.com/u/mangelet)\
**Post date:** [March 11, 2022, 8:49am UTC](https://community.hubspot.com/t/3rd-party-integration-how-to-create-fine-grained-scope/52784/4 "2022-03-11T08:49:13Z")

</div>

Serverless functions provide a way to write server-side code that interacts with HubSpot and third-party services.

You can use whatever you want. HubSpot serverless functions are available through CMS Enterprise, but any serverless service out there works.
