---
title: "Discussion on \"SaaS REST for VPD Multi-Tenant APEX Apps\" | Hashnode"
description: "Discussion on \"SaaS REST for VPD Multi-Tenant APEX Apps\". Whats this all about?\nIn a SaaS model, APEX provides an apex_session.set_tenant_id procedure to set a context. This context can be accessed by your VPD in determining the rows the user can access.\nHowever with REST, I have some questions...\n\nHow do y..."
url: "https://hashnode.com/posts/saas-rest-for-vpd-multi-tenant-apex-apps/65eeca720ac778cd331d47ac"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [SaaS REST for VPD Multi-Tenant APEX Apps](https://mattmulvaney.hashnode.dev/saas-rest-for-vpd-multi-tenant-apex-apps?utm_source=hashnode&utm_medium=feed)

Whats this all about? In a SaaS model, APEX provides an apex\_session.set\_tenant\_id procedure to set a context. This context can be accessed by your VPD in determining the rows the user can access. However with REST, I have some questions... How do y...

Mar 11, 2024 · 10 min read · mattmulvaney.hashnode.dev  
Read the article

-   [#orclapex](https://hashnode.com/tag/orclapex)
-   [#rest-api](https://hashnode.com/tag/rest-api)
-   [#ords](https://hashnode.com/tag/ords)

## Written by

[Matt Mulvaney](https://hashnode.com/@lufcmattylad)

@lufcmattylad

  
[View profile](https://hashnode.com/@lufcmattylad)

I do fancy stuff with Oracle APEX #orclapex

With around 20 years on the job, Matt is one of the most experienced software developers at Pretius. He likes meeting new people, traveling to conferences, and working on different projects. He’s also a big sports fan (regularly watches Leeds United, Formula 1, and boxing), and not just as a spectator – he often starts his days on a mountain bike, to tune his mind.

## Responses 1

Markdown supported · ⌘↵ to post

[Neil Fernandez](https://hashnode.com/@neilfernandez)

[Mar 11, 2024](https://hashnode.com/posts/saas-rest-for-vpd-multi-tenant-apex-apps/65eeca720ac778cd331d47ac/comment/65ef08d9aa085cca840b9bd8)

Hi Matt,

Fantastic write up!

Want to note that this example now requires the use of setting up an APEX session for an ORDS handler whereas before there was no APEX session. So, this adds a **small** amount of overhead to each REST call which VPD requires set up regardless. One **_may_** want to consider using their own custom Context that they manage the set up of it **_if_** that becomes an issue. It should not be an issue for most. The write up above is ideal for the majority! Just wanted to add that in.

Also, for point 14 you mentioned QuickSQL breaks without that grant? Mind sharing that part? I did not see mention of QuickSQL until that part so wondering if that is a typo or if not would like to investigate what is occurring.

Best, Neil

[Matt Mulvaney](https://hashnode.com/@lufcmattylad)

[Mar 11, 2024](https://hashnode.com/posts/saas-rest-for-vpd-multi-tenant-apex-apps/65eeca720ac778cd331d47ac/comment/65ef08d9aa085cca840b9bd8#reply-65ef191cd4ddbfb93477da0f)

Regarding QuickSQL, I haven't been able to reliably reproduce. I'll keep the grant, but lose the reference to QuickSQL

[Neil Fernandez](https://hashnode.com/@neilfernandez)

[Mar 11, 2024](https://hashnode.com/posts/saas-rest-for-vpd-multi-tenant-apex-apps/65eeca720ac778cd331d47ac/comment/65ef08d9aa085cca840b9bd8#reply-65ef1a1559f2b11653c16ccd)

[Matt Mulvaney](https://hashnode.com/@lufcmattylad)

You are correct! I just wanted to denote that there **_may_** be a need to deviate, but I believe creating a session, setting tenant\_id, by the APEX API's is definitely preferred/only approach when using the provided tenant system from APEX. So, the write up is perfect.

I will raise an ER to see if there can be a version (specific for ORDS) that does not require creating an APEX session :)

[Neil Fernandez](https://hashnode.com/@neilfernandez)

[Mar 11, 2024](https://hashnode.com/posts/saas-rest-for-vpd-multi-tenant-apex-apps/65eeca720ac778cd331d47ac/comment/65ef08d9aa085cca840b9bd8#reply-65ef1e78ce5823b87dd07181)

[Matt Mulvaney](https://hashnode.com/@lufcmattylad)

Ah so if you create a prehook, and don't execute the grant, it sometimes breaks QuickSQL?
