Register an External Service

Learning Objectives

After completing this unit, you’ll be able to:

  • Define a Named Credential for your external web service.
  • Add an external web service using a provided schema.
  • Explain how the External Service actions relate to the schema definition you use.

First things first: Named Credentials and Endpoint Access

Before we enter the world of External Services, we have some prerequisites to complete. In the past unit, we covered schemas and what constitutes a valid and supported one for External Services. In addition to a supported schema, we need a simple way to secure our external web service and our Salesforce org. For this task we can use Named Credentials to authenticate our endpoint callouts. 

In a typical project, the external web service provider would supply the elements for a Named Credential. Those elements include the URL of a callout endpoint and its required authentication parameters. In the last unit, we said that schemas contain the endpoint information and authentication parameters for the REST-based API web services. We’re going to use this information to define a Named Credential for our org. Go ahead and try it out in your Trailhead Playground.
  1. From Setup, enter Named Credentials in the Quick Find box, then select Named Credentials.
  2. Click New Named Credential.
  3. For Label, use Bank.
  4. For URL, use https://th-external-services.herokuapp.com
  5. Leave other fields as they are and click Save.
You’ll find more resources on authentication and Named Credentials at the end of this unit.

Use the External Services Wizard to Register Your Web Service

Now we get to register the web service. Because we have a valid schema (a real-world example would additionally set the authentication protocol in Named Credential), this part is simple. Adding our Acme bank external service in External Services tells Salesforce how it will interact.  

  1. From Setup, enter External Services in the Quick Find box, then select External Services.
  2. Click Add an External Service.
  3. For External Service Name, enter BankService (no space).
  4. For Select a Named Credential, select Bank.
  5. Select Service Schema Relative URL, and enter /accounts/schema  The full URL from our service provider is located here: https://th-external-services.herokuapp.com/accounts/schema.
  6. Click Save & Next.
  7. Select operations.
  8. Click Next. Take a look at the External Service Actions and when you’re ready, click Done.

A list of your External Service actions appears. Use the scrollbar to view them all.

These actions are now available to you in Flow Builder. We’ll create a simple flow in the next unit and show you how to find the actions in the Flow palette. For now, let’s look at the getAccount method and some of its parameters.

  • The getAccount method retrieves account information.
  • The accountName parameter specifies the account.
  • There are several output parameters for the getAccount method, too. The codes, such as 200, correlate to specific response codes defined in the schema. You can also see these definitions nicely formatted in the Swagger Editor when you validate the schema.
If you’ve been with us since unit one, we’ve now covered the first four steps discussed in that unit:
  1. An external services provider, such as a bank, shares their REST-based API schema specification: We got this information from our fictional bank.
  2. Based on the specification, the service provider (like our credit service example) a developer (or maybe you) creates a JSON-based schema definition that describes the API: While we didn’t create this schema ourselves, we reviewed the elements of a schema and the requirements for a supported one. When you work with external services, you or your developer can define the schema you need for your use case.
  3. A Salesforce administrator declaratively creates a Named Credential to authenticate to the service endpoint using the URL provided by the external service provider: We defined our named credential, https://th-external-services.herokuapp.com.
  4. A Salesforce administrator declaratively registers the service and uses both the schema definition and Named Credential during the registration process: We just registered our first external service and looked at the actions in the wizard.

Keep learning for
free!
Sign up for an account to continue.
What’s in it for you?
  • Get personalized recommendations for your career goals
  • Practice your skills with hands-on challenges and quizzes
  • Track and share your progress with employers
  • Connect to mentorship and career opportunities