Overview

What is the Fetch capability? How does it work?

The Fetch capability lets apps send HTTP requests to a third-party server. This unlocks a huge range of possibilities, such as integrating with external services and performing CPU-heavy tasks.

Benefits

  • Run code that can't (or shouldn't) run in the browser.
  • Build apps that connect to existing APIs.

Lifecycle

  1. The app initializes the Fetch capability.
  2. The app calls a method to send a request to a registered endpoint.
  3. The request is sent via Canva's backend.
  4. The app's backend responds to the request.
  5. The response is sent back to the app's frontend via Canva's backend.
  6. The method that sent the request returns the details of the response.

Limitations

  • Apps can only send POST and GET requests.
  • The Content-Type of all POST requests is application/json.
  • The Content-Type of all responses must be application/json.
  • A request can only contain a body or query parameters, not both.
  • The maximum combined size of the headers and the body or params is 512kb.
  • The names of custom headers must be prefixed with X-, such as X-My-Custom-Header.
  • The names of headers must not conflict with the headers that Canva includes with all requests, such as X-Canva-Timestamp.
  • An app’s backend must respond to requests within 3 seconds (or implement polling).