https://your-api.jojapi.net.
Every API runs on the edge gateway as its own Worker, and the Worker tab shows the template described here. A new API starts with an empty template: until you save its origin, requests to it answer
424 No available API targets and are not billed. The My APIs list shows what each API’s Worker runs: Template (generated from the template) or Code (your own Worker code).The template
Origins: one or more base URLs including any path prefix, e.g.https://api.example.com/v2. The consumer’s path and query string are appended as they are: /users/42?x=1 reaches https://api.example.com/v2/users/42?x=1. With several origins a request goes to one of them at random and moves on to the next when the first does not answer (network error or timeout), which gives you simple load balancing and failover. IP addresses and non-standard ports work too; such requests leave through the platform’s egress relay. A variable may stand in for the host: https://{env.HOST}.
HTTP method: the consumer’s method, or an override.
Timeout: up to 90 seconds per origin (the platform’s maximum).
Request headers and query parameters: add or overwrite values (a header can also be removed from the forwarded request). Values accept placeholders.
Switches:
- Forward the consumer’s headers — off means only the headers you set reach the origin.
- Forward the consumer’s query string — off means only the parameters you set are sent.
- Consumer context headers — sends
x-jojapi-user-id,x-jojapi-user-nick,x-jojapi-user-planandx-jojapi-endpoint-creditsto the origin.
Beyond the template
Different origins or paths per endpoint, response rewrites, request body transformations, several upstream calls per request, or usage computed from the response body are matters of code. View generated code shows the Worker the template produces; Edit code takes it over. APIs that had endpoint-specific targets on the classic gateway were moved in code mode, with generated code that behaves exactly like those targets did. See Worker code.Placeholders
Header values and query parameters interpolate{placeholder} values from the request and the consumer’s account:
The Vars button on each field lists them, including your variables.
Variables
Variables are named values bound to your API’s Worker. Use them for anything you would rather not type into the template: upstream API keys, tokens, a proxy URL.- Secret variables are encrypted at rest and never shown again after you save them. To rotate one, save a new value under the same name.
- Plain variables are shown in Studio; use them for non-sensitive settings such as a region or a version.
{env.NAME} in the template, or read env.NAME in code. Names use capital letters, digits and underscores, for example UPSTREAM_API_KEY.
A variable the template uses cannot be deleted: remove it from the template first, and deploy that change if production still runs a template that uses it.
Recognize requests with a secret header
Requests from the gateway do not come from fixed IP addresses (most leave from Cloudflare’s network, which every Cloudflare customer shares), so filtering by IP address cannot tell JoJ API apart. Have the template send a header that only JoJ API knows, and let your server accept only requests that carry it:-
Save a long random value (32 characters or more) as a secret variable such as
ORIGIN_SECRET. -
Add a request header to the template, for example
X-Origin-Secret, set to{env.ORIGIN_SECRET}. -
Make your server reject requests without that header and value:
In application code, compare the value with a constant-time comparison.
- Check that your API still answers through the gateway.
