Continuation
When Canva sends an HTTP request to endpoints, it limits the number of resources that can be included in the response. For example, when Canva sends a request to the /content/resources/find
endpoint, the endpoint must respond with 100 or fewer resources.
If an extension needs to respond with more resources than this limit allows, it can use continuation to deliver the resources across multiple requests and responses.
This topic explains what continuation is and how to support it.
Continuation is also known as cursor-based pagination.
Request-response cycle
Any endpoint that returns a list of resources can support continuation, including:
If an endpoint supports continuation, it can include a continuation
property in the response body:
{"type": "SUCCESS","resources": [],"continuation": "<continuation_token>"}
This property must contain a continuation token. A continuation token is a string of characters that, when passed back to the server, identifies how to return the next logical batch of resources. It can be as simple as a page number or a complex string that encodes more information.
The presence of the continuation
property tells Canva to send another request to the endpoint when more resources are required, such as when a user scrolls through content in a content extension.
The subsequent request that Canva sends has a continuation
property in the request body. This property contains the continuation token from the previous response:
{"limit": 100,"user": "<user>","brand": "<brand>","label": "<label>","locale": "<locale>","type": "<type>","continuation": "<continuation_token>"}
The endpoint can use the token to respond with the relevant resources. For example, if the continuation
property contains a value of "2"
, the endpoint can identify and return the resources that belong to that page.
When there are no more resources to retrieve, the endpoint can set the continuation
property in the response body to null
:
{"type": "SUCCESS","resources": [],"continuation": null}
This tells Canva to stop sending additional requests to the endpoint.
Further reading
- Paginating Requests in APIs(opens in a new tab or window) (medium.com)
- “Cursor Pagination” Profile(opens in a new tab or window) (jsonapi.org)
- How to implement cursors for pagination in an api(opens in a new tab or window) (stackoverflow.com)
Next steps
To learn how to add continuation to an extension, see the following guides: