Oauth 2.0 API Issue ServiceTitan - Works in postman

Hi all, I am having an issue initilizing a call to ServiceTitan to return a Auth token… Here is the documentation from ST :
330. Docs: Make Your First API Call - ServiceTitan API - developer portal

I have everything set up to this point, and Ive created an API in bubble api plugin


Ive also tried it by importing curl, and setting it up that way. Ive tried it with and without creating parameter brackets < > …etc…

Everytime I run I get

In postman, it works fine

Now, if I take the token from postman that is generated, I can use it and make API calls from Bubble this way:
(I fill the values from a form fill on the app)

What I am trying to accomplish is that the user on my SaaS app can connect to their service titan, and then use the data elsewhere in the app through api call actions.

I am thinking they need to connect (initialize the token) and then store the token to use in subsequent calls… this token refreshes but I am not there yet, right now, I want to get the call working…)

Any help would be appreciated. TIA! :frowning:

You’re passing the values as URL params i.e. https://…?grant_type=…&client_id=…

In postman, you’re passing them as data via the body. This would probably be the issue.

So yeah that screenshot was from a test changing it up but Ive done it this way, still same error

Am I missing something here?

Okay so I tried something different and still getting a 400 error. Here is what I did


I created it as a custom token, I created an API call because its the only way to make action for a workflow yeah?

I went ahead and did a manual response with the response from postman, I went and added a workflow,



The error I get is

If I can just get the token to work, the rest of the calls I make subsequently using the token are all working. :frowning:

Can anyone please walk me through this?

The first thing is that you should use Custom oAuth token instead of manually add the authorization token to all call. Probably you will pass the value as https://auth-integration.servicetitan.io/connect/token?grant_type=client_credentials&client_id=YOURCLIENTID&client_secret=YOURCLIENTSECRET (and maybe set the header for content-type= application/x-www-form-urlencoded (don’t use shared header but token call header. But this is probably not needed)

This way, you will not need to manually add authorization header to all call. Bubble will do it for you.

In the first screenshot, it probably didn’ work because you didn’t select POST… Also, shared header shouldn’t be set for the content-type: application/x-www-form-urlencoded. You will have a conflict with other call that will need application/json.

1 Like

On my last reply I had started using custom oauth token after realizing… but can you walk me through using the url a bit or point me to a resource?

UPDATE: Thanks for the guidance Jici I got it to work using

1 Like

Hey I am unable to get this to work. Can you confirm your setup?
Did you keep your 1st section body as that JSON snippet?
If you selected Raw as Body type in the 2nd section, is this the literal payload:
grant_type=client_credentials&client_id=&client_secret=

or did you put your creds in there? I feel like I’ve tried every which way based on yours and Jicis recommendations (I have indeed tried putting my creds after each = sign, and data type JSON in that second section there) and I just cannot figure it out. I’ve been successful in python using requests and BASH using curl but not here. TIA

You don’t need to use an API call + custom token
Your request in oauth2 custom token section use JSON while request should be x-www-form-urlencoded. This is what you are doing in API Call (but not correcly…). You should use that in Body for token. Nothing should be dynamic with client credentials…
If it doesn’t work in body, try to put everything in the url directly like ?grant_type=client_credentials&client_id=yourclientid&client_secret=yourclientsecret

Hi thank you for your response! I have tried 3 different ways of doing this based on your recommendations:
In Token endpoint POST url:
https://auth.servicetitan.io/connect/token?grant_type=client_credentials&client_id=cid.1234&client_secret=cs1.1234

In Body:
?grant_type=client_credentials&client_id=cid.1234&client_secret=cs1.1234
grant_type=client_credentials&client_id=cid.1234&client_secret=cs1.1234

Nothing seems to be working. Usually when I am debugging BASH curls/python requests I can at least see the form of the request as it is sent, so that I may check if there are syntax issues,. Here, however, I do not have the ability to do so here and not sure how to proceed.

Remove the ? in body, you don’t need it. After, add an API call, not the token one. This is done by Bubble with auth. Like https://api.servicetitan.io/crm/v2/tenant/{tenant}/export/leads (Replace tenant by your value)

You can always replace url by an url from a service like requestbin to see the request sent.