I'm trying to see how to create a new Case based on an alert being generated in a basic Grafana system. From what I understand, any "generic" integrations from Grafana to other systems should be via a webhook, it's not possible to execute an arbitrary local script etc.

Being very new with Salesforce, and just a peripheral user of it, not an admin, I see lots of references to Apex classes and webhooks in the SF dev docs, but it feels very complicated given I've also happily got some simple (unrelated) scripts using the REST API in python. I'd certainly rather not need to have some new dedicated listener at some level, that seems to be heading into a very overblown solution.

So I'm after any steer on, in the first instance, the best way I can create a new case in Salesforce with a single POST from outside. I can specify Basic Auth credentials or an arbitrary Bearer header. I would like to think I can have a predefined token and just send it directly to the REST API with a suitable templated JSON (or other) payload. Is this feasible though? I'm seeing mention of JWT tokens, which seem to allow a single shot process, but I'd really appreciate some more preliminary guidance on it!

Outside of Webhook, I think the only other simple interface is email, but that hardly seems like an approach to take on a blank slate, any Grafana fans welcome to chip in too!

1 Answer 1


Well, there's good news and bad news.

The good news is that you can create a Case with a single POST request. This example, creating a new Account is pretty much what you're looking for. Substitute Account with Case in the URL, provide some appropriate JSON (e.g. Case doesn't have a Name field, you'd use Subject instead) and you should be off to the races.

The bad news is that you can't just use a static token to get authorization to use Salesforce's REST API.

  • You need to create a "Connected App" in Salesforce
  • Which will give you a consumer id and secret
  • Which you'll need to use to go through one of the OAuth 2.0 flows (probably the "client credentials" flow, though the JWT Bearer flow would be another option)
  • Which provides you with a time-limited token that you'd be able to use to call the REST API

The Client Credentials and JWT flows are "headless", meant for server-server actions and where it's impossible to display a window for a user to enter their own (sfdc) credentials and allow the connected app to act on their behalf.

OAuth is pretty common in the web api sphere, and you'd likely run into it if you try to integrate with any other major platform (and possibly any other middleware that would handle integration with Salesforce for you like Talend/Jitterbit/MuleSoft/etc...)

  • Thanks. Not being familiar enough with Oauth2, I'm wondering if it is compatible with what Grafana can offer, If not using HTTP Basic Auth, the other option is to literally just supply a Bearer header with a fixed content. I can imagine that the token creation and such could be done out of band, as long as a suitable bearer string can last 6 months or something, but this is feeling somewhat unlikely...? This morning I'm more thinking about running a small Flask instance to accept the webhook and then convert that into a REST API call with an existing API Only, non password expiring user.
    – user145214
    Feb 2 at 8:40
  • @user145214 The maximum (nominal) lifetime of an access token is 24 hours, and whichever route you end up going you should expect that your token needs to be able to be changed. In practice, a token can live forever if you make calls to Salesforce frequently enough (The token's expire time is reset if you make a request with it in the last 50% of its lifetime. I.e. If you get a token at 1 PM, and it has a timeout of 2 hours (so expires at 3 PM), if you make a request at 2:15 PM then the token will be good until 4:15 PM)
    – Derek F
    Feb 2 at 13:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .