PowerApps can leverage any RESTful APIs hosted anywhere. This tutorial demonstrates registering and using a custom API.

Prerequisites

  • A PowerApps account.
  • A Swagger file (JSON) OR a URL to a Swagger definition for your custom API. If you don't have one, we'll show you several options to create the Swagger file.
  • An image to use as an icon for your custom API (optional).

Authentication

Custom APIs in PowerApps can use any of several authentication mechanisms

  • API Key
  • Basic Authentication
  • Generic OAuth 2.0
  • OAuth 2.0. The specific implementations below are currently supported, with more coming soon.

    • Azure Active Directory
    • Box
    • Dropbox
    • Facebook
    • Google
    • Instagram
    • OneDrive
    • SalesForce
    • Slack
    • Yammer

The OpenAPI Specification describes how to specify authentication within a Swagger.

If your API endpoint allows unauthenticated access, you should remove the securityDefintions object from the OpenAPI (Swagger) file. In the following example, remove all of the following securityDefintions object:

  "securityDefinitions": {
    "AAD": {
      "type": "oauth2",
      "flow": "implicit",
      "authorizationUrl": "https://login.windows.net/common/oauth2/authorize",
      "scopes": {}
    }
  },

Examples

Register a custom API

Step 1: Create a Swagger file

You can create a Swagger file from any API endpoint, including:

  • Publicly available APIs. Some examples include Spotify, Uber, Slack, Rackspace, and more.
  • An API that you create and deploy to any cloud hosting provider, including Amazon Web Services (AWS), Heroku, Azure Web Apps, Google Cloud, and more.
  • A custom line-of-business API deployed on your network as long as the API is exposed on the public internet.

When you create the Swagger file, a JSON file is created. You'll need this is Step 2.

Connecting to Azure App Service or Azure Functions

If your API is built with Azure App Service or Azure Functions, see Exporting an Azure hosted API to PowerApps to learn more.

Getting help with Swagger files

Step 2: Register the custom API

Now that the Swagger file (JSON file) is generated for the custom API, register the custom API in PowerApps

  1. In powerapps.com, in the menu on the left, click Connections. Then click ... and select Manage custom APIs in the upper-right corner.

    Tip:

    If you can't find the menu, it may be under a hamburger button in the upper-left corner in mobile browsers.

    Create custom API

  2. Select New custom API:

    Custom API properties

    You will be prompted for the properties of your API.

    Property Description
    Swagger URL OR Swagger API definition Paste a URL to a Swagger definition OR browse to the JSON file created from Swagger.
    Name Type the name of your custom API.
    Upload API icon Browse an image file for the icon (optional).
    Description Type a description of your custom API (optional).

    Select Next.

  3. Enter any authentication properties. If the JSON file uses OAuth2 authentication in the securityDefintions object, you are prompted for the following values:

    Property Description
    Client id Using one of the supported OAuth identity providers, a client ID is provided. Type this client ID.
    Client secret Type the client secret from the identity provider you chose.

    Refer to Azure Resource Manager and Azure WebApp examples to learn how to configure AAD authentication values.

    If the JSON file does not use the securityDefintions object, then no additional values may be needed.

  4. Select Create.

    Your custom API is now displayed under Custom.

    Available APIs

    Tip:

    If the Swagger file fails to validate, there may be extra characters. For example, most data should be in quotes, including website URLs.

  5. Now that the custom API is registered, you must create a connection to the custom API so it can be used in your apps. Click the + to the right of the Modified date of your custom API and then complete any necessary steps to sign in to your API's data source. If you're using OAuth authentication with your API, you might be presented a sign-in screen. For API Key authentication, you might be prompted for a key value.

Step 3: Add the custom API to an app

Add the custom API to an app as you would any other data source, and then use the API within the function bar, a text box, and more. For example, in the function bar, you can start typing MySampleWebAPI to see the available functions. Office 365 Outlook is an example of using the Office 365 API.

Share a custom API

Users can also share custom APIs with each other.

  1. In powerapps.com, in the menu on the left, click Connections. Then click ... and select Manage custom APIs in the upper-right corner.

    New connection

  2. Select your API, select Share, and then enter the users or groups to whom you want to grant access to your API.

    Share custom API

  3. Select Save.

Note:

You may only share custom APIs with other users in your organization.

Quota and throttling

  • See the PowerApps Pricing page for details about custom API creation quotas. Custom APIs that are shared with you don't count against this quota.
  • For each connection created on a custom API, users can make up to 500 requests per minute.
  • Keep in mind that deleting a custom API deletes all the connections created to the API.
  • The size of your Swagger file should be under 1MB.

Next steps

Learn about custom Swagger extensions.

Use an ASP.NET Web API.

Register an Azure Resource Manager API.