Get image generation job
This API is currently provided as a preview. Be aware of the following:
- There might be unannounced breaking changes.
- Any breaking changes to preview APIs won't produce a new API version.
- Public apps that use preview APIs will not pass the review process, and can't be made available to all Canva users.
Gets the result of an image generation job that was created using the Create image generation job API. Only the app and user that created the job can get it.
If the job is successful, the job's result contains a download URL for the generated image. The download URL is only valid for 24 hours. If the job was created with asset_upload set to type: upload, the result also contains the image asset that the image was saved as. These jobs stay in_progress until the asset has finished importing, so the returned asset is ready to use.
You might need to make multiple requests to this endpoint until you get a success or failed status. For more information on the workflow for using asynchronous jobs, see API requests and responses.
HTTP method and URL path
https://api.canva.com /rest /v1 /image-generations/{jobId}This operation is rate limited to 120 requests per minute for each user of your app.
Authentication and authorization
This endpoint requires a valid access token that acts on behalf of a user.
Scopes
The access token must have all the following scopes (permissions):
asset:write
Header parameters
Path parameters
jobIdstringThe image generation job ID.
Example request
Examples for using the /v1/image-generations/{jobId} endpoint:
curl --request GET 'https://api.canva.com/rest/v1/image-generations/{jobId}' \--header 'Authorization: Bearer {token}'
const fetch = require("node-fetch");fetch("https://api.canva.com/rest/v1/image-generations/{jobId}", {method: "GET",headers: {"Authorization": "Bearer {token}",},}).then(async (response) => {const data = await response.json();console.log(data);}).catch(err => console.error(err));
import java.io.IOException;import java.net.URI;import java.net.http.*;public class ApiExample {public static void main(String[] args) throws IOException, InterruptedException {HttpRequest request = HttpRequest.newBuilder().uri(URI.create("https://api.canva.com/rest/v1/image-generations/{jobId}")).header("Authorization", "Bearer {token}").method("GET", HttpRequest.BodyPublishers.noBody()).build();HttpResponse<String> response = HttpClient.newHttpClient().send(request,HttpResponse.BodyHandlers.ofString());System.out.println(response.body());}}
import requestsheaders = {"Authorization": "Bearer {token}"}response = requests.get("https://api.canva.com/rest/v1/image-generations/{jobId}",headers=headers)print(response.json())
using System.Net.Http;var client = new HttpClient();var request = new HttpRequestMessage{Method = HttpMethod.Get,RequestUri = new Uri("https://api.canva.com/rest/v1/image-generations/{jobId}"),Headers ={{ "Authorization", "Bearer {token}" },},};using (var response = await client.SendAsync(request)){response.EnsureSuccessStatusCode();var body = await response.Content.ReadAsStringAsync();Console.WriteLine(body);};
package mainimport ("fmt""io""net/http")func main() {url := "https://api.canva.com/rest/v1/image-generations/{jobId}"req, _ := http.NewRequest("GET", url, nil)req.Header.Add("Authorization", "Bearer {token}")res, _ := http.DefaultClient.Do(req)defer res.Body.Close()body, _ := io.ReadAll(res.Body)fmt.Println(string(body))}
$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => "https://api.canva.com/rest/v1/image-generations/{jobId}",CURLOPT_CUSTOMREQUEST => "GET",CURLOPT_RETURNTRANSFER => true,CURLOPT_HTTPHEADER => array('Authorization: Bearer {token}',),));$response = curl_exec($curl);$err = curl_error($curl);curl_close($curl);if (empty($err)) {echo $response;} else {echo "Error: " . $err;}
require 'net/http'require 'uri'url = URI('https://api.canva.com/rest/v1/image-generations/{jobId}')http = Net::HTTP.new(url.host, url.port)http.use_ssl = truerequest = Net::HTTP::Get.new(url)request['Authorization'] = 'Bearer {token}'response = http.request(request)puts response.read_body
Success response
If successful, the endpoint returns a 200 response with a JSON body with the following parameters:
jobImageGenerationJobDetails about the image generation job. If the job status is success, the job's
result is present.
idstringThe image generation job ID.
statusstringThe status of the image generation job. A newly created job will be in_progress and
will eventually become success or failed. If the status is success, the job's
result is present.
Available values:
failedin_progresssuccess
resultImageGenerationJobResultResult of the image generation job. Only present if job status is success.
imageGeneratedImageA generated image.
urlstringA download URL for the generated image. The download URL is only valid for 24 hours.
widthintegerThe width of the generated image in pixels.
heightintegerThe height of the generated image in pixels.
assetobjectThe image asset the generated image was saved as. Only present if the job was created
with asset_upload set to type: upload and the asset still exists (for example, it's
absent if the user has since deleted the asset).
typestringType of an asset.
Available values:
imagevideo
idstringThe ID of the asset.
namestringThe name of the asset.
created_atintegerWhen the asset was added to Canva, as a Unix timestamp (in seconds since the Unix Epoch).
updated_atintegerWhen the asset was last updated in Canva, as a Unix timestamp (in seconds since the Unix Epoch).
thumbnailThumbnailA thumbnail image representing the object.
widthintegerThe width of the thumbnail image in pixels.
heightintegerThe height of the thumbnail image in pixels.
urlstringA URL for retrieving the thumbnail image. This URL expires after 15 minutes. This URL includes a query string that's required for retrieving the thumbnail.
errorImageGenerationErrorIf the image generation job fails, this object provides details about the error. Only present if status is failed.
codestringError code indicating what went wrong with the image generation.
Available values:
unsafe_input: Content safety checks rejected the prompt.timeout: The generation did not complete in time.model_not_available: The requested model can't currently serve this request, and Canva doesn't retry the job with another model. This is usually temporary. Retry later, retry without themodelparameter to use automatic model selection, or retry with a different model.model_retired: The requested model has been permanently retired from this version of the API, and you can't use it again in this version. Use a different model. The API documentation lists retired models, which keep their enum value for the lifetime of this API version.internal_error: An unexpected error occurred during generation.
messagestringA human-readable description of what went wrong.
Example response
{"job": {"id": "string","status": "failed","result": {"image": {"url": "string","asset": {},"width": 1024,"height": 1024}},"error": {"code": "unsafe_input","message": "string"}}}
Error responses
401 Unauthorized
codestringA short string indicating what failed. This field can be used to handle errors programmatically. For a complete list of error codes, see Error responses.
messagestringA human-readable description of what went wrong.
Example error responses
The OAuth client credentials are invalid
{"code": "invalid_client","message": "Client {clientId} not available"}
Access token could not be decoded or signature could not be verified.
{"code": "invalid_access_token","message": "Access token is invalid"}
Client credentials or body auth are missing from the request
{"code": "invalid_client","message": "Client credentials or body auth are missing from the request."}
Authorization header has wrong number of components
{"code": "invalid_access_token","message": "Malformed Authorization header: wrong number of components"}
Authorization header has invalid mode
{"code": "invalid_access_token","message": "Malformed Authorization header: invalid mode"}
Token couldn't be introspected
{"code": "invalid_access_token","message": "Token couldn't be introspected"}
Access token is revoked
{"code": "revoked_access_token","message": "Access token is revoked"}
Missing Authorization header
{"code": "invalid_access_token","message": "Missing Authorization header"}
Malformed Authorization header
{"code": "invalid_access_token","message": "Malformed Authorization header"}
403 Forbidden
codestringA short string indicating what failed. This field can be used to handle errors programmatically. For a complete list of error codes, see Error responses.
messagestringA human-readable description of what went wrong.
Example error responses
The required OAuth scope is missing
{"code": "missing_scope","message": "Missing scopes: {scopes}"}
Request must be made on behalf of a user
{"code": "user_role_required","message": "This request must be made on behalf of a user."}
Not allowed to access the integration
{"code": "permission_denied","message": "Not allowed to access integration with client id {clientId}"}
404 Not Found
codestringA short string indicating what failed. This field can be used to handle errors programmatically. For a complete list of error codes, see Error responses.
messagestringA human-readable description of what went wrong.
Example error response
The image generation job was not found
{"code": "not_found","message": "Image generation job not found: {jobId}"}
429 Too Many Requests
codestringA short string indicating what failed. This field can be used to handle errors programmatically. For a complete list of error codes, see Error responses.
messagestringA human-readable description of what went wrong.
Example error responses
Rate limit exceeded
{"code": "too_many_requests","message": "Too many requests to {operation}"}
Throttled because too many requests
{"code": "too_many_requests","message": "Throttled because too many requests"}