Fallback in expression syntax

I have a workflow that runs on two different events: pull_request and manually. It looks like this:

on:
  pull_request:
    branches: [master]
  workflow_dispatch: {}

env:
  API_URL: https://example.com/

What I want is to be able to set an alternate API_URL when I trigger the workflow manually. But I want the workflow to run the same when it runs automatically.
So, first, I add “inputs” to the workflow_dispatch:

on:
  pull_request:
    branches: [master]
  workflow_dispatch:
    inputs:
      API_URL:
        description:
        required: true
        default: https://example.com

env:
  API_URL: ${{ github.event.API_URL }}

From what I understand, this way the API_URL env variable will only be set when the workflow is run manually. But when it’s run automatically, there’s no github.event.API_URL value.

It seems to me that a conditional fallback here is needed.
Will something like this work?

env:
  API_URL: ${{ github.event.API_URL || 'https://example.com/' }}

But from the docs the || operator will evaluate to 1 or 0.

Is there a good way to solve this? Thanks!