Parsing 401 status code from API response

I am building bubble app on top of REST apis’ that use jwt tokens for
authentication. When the token is expired I get a json response like
{“detail”:“Access Token has expired”} with status code 401.

With a valid jwt token I get the required data as json with response status
code as 200. I would like to make a GET method call to a token/refresh
endpoint that returns a new jwt token, along with a refresh token.

How do I check if the response status code is 401 and if so make a call to
token/refresh endpoint to get a new token?

Some options
A) Use Unhandled error occurs and check if the error message contain Access token has expired
B) Activate “Include error in response and continue WF” and have similar process to check if the previous step have an error or not and get a new token.
C) Store expiration date in DB and check if the token is expired before doing another call.

1 Like

@anon69995196, you can check the response status code after enabling “Include errors in response and allow workflow actions to continue” in the settings for the API-call in Bubble’s API connector plugin.

After you enable this setting, you probably need to re-initialize the API-call and after that the codes are available in the workflow, f.i. as conditions to perform or not perform certain steps. In your case to perform the step to refresh the API-token when a 401 is returned:

You will need to test a little bit but the condition will look something like this:


Here is the Bubble documentation.

Best regards,


1 Like

Hi @gerbertdelangen

I have enabled “Include errors in response and allow workflow actions to continue” in the settings. I am getting the status code in the Initialization of the call but I am unable to get the status code & message value in the workflow. Any help would be appreciated!