Skip to content

Updating visuals

If you see any images containing outdated UI, please bear with us.

We are updating all content as quickly as possible to mirror our new UI.

Return

Securing APIs

Protect your APIs so only the right users can access sensitive data.

Steps at a glance ​

  1. Create an API from the API Endpoints tab in the Backend Workflows subtab of Data & API.
  2. Open Security on the API endpoint so it requires a signed-in user (and roles if needed).
  3. Test the API in preview mode and confirm it is blocked when signed out.

1) Set Security on the API endpoint ​

  1. Open the Data & API tab, then open the Backend Workflows subtab and go to API Endpoints.
  2. Select your API endpoint.
  3. Click the access button at the top of the endpoint (it shows Public or Auth) to open the Security panel, then set:
    • Public for endpoints anyone can access.
    • Authenticated for endpoints that require a signed-in user.
    • Role-based rules when only certain roles should have access: with Authenticated, choose Match any or Match all, then select the roles.
The API Endpoints of Backend Workflows with the Clean task name endpoint selected and its Security panel open from the Auth button, set to Authenticated with Match any and the roles select

2) Return clear responses ​

When a call is blocked, WeWeb returns an error: 401 if the user is not signed in, 403 if they do not have the required role. Call the endpoint inside a Try/Catch action and show a helpful message in the Catch branch:

  • If the user is not signed in, show a helpful message (for example “You must sign in to continue.”).
  • If the user is signed in but not allowed, show a message like “You do not have access to this.”

Learn more about Try/Catch →

3) Test it quickly ​

  1. In preview mode, trigger the API from your interface.
  2. Test while signed in and while signed out.
  3. Confirm the result matches your Security settings.

Common pitfalls ​

Your API works in preview but fails in production ​

  • Check that your production environment uses the same SSO Providers settings and environment variables.

You can still access the API from a public page ​

  • Make sure the API endpoint itself is protected with Security settings (not only the page).