Handling test vs live in APIs

Options
aemondis
aemondis Member
edited October 2023 in ? Working with APIs

Hi, I'm currently building up numerous APIs for a semi-live app, but having a few challenges in trying to determine if I'm working with a test or live source environment (in my case, bubble).

I already pass the X-Data-Source header from my bubble test instance, but my APIs also leverage external services for things like SMTP - of which also has a test and live environment. My goal is that if a request from bubble is targeting the "test" data source, I would like to also pass that request to my "test" SMTP service, so I am not ruining my delivery reputation by sending to garbage emails. As far as I can tell, there doesn't seem to be any way within an API workflow to check what data source is currently being targeted, or any other parameter that I can use to check if it's a test or live API request.

Is there any way in the API workflow to determine which data source was requested?

Comments

  • aemondis
    aemondis Member
    Options

    Looks like I've answered my own question, after spending hours trying to find a solution to this!!! Murphy strikes again…

    For those struggling with this kind of scenario - there is a "$datasource" environment variable you can retrieve: