0

License images

by
Published Oct 17, 2025

This endpoint gets licenses for one or more images. You must specify the image IDs in the body parameter and other details like the format, size, and subscription ID either in the query parameter or with each image ID in the body parameter. Values in the body parameter override values in the query parameters. The download links in the response are valid for 8 hours.

Script shutterstock Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Shutterstock = {
3
  token: string;
4
};
5
/**
6
 * License images
7
 * This endpoint gets licenses for one or more images. You must specify the image IDs in the body parameter and other details like the format, size, and subscription ID either in the query parameter or with each image ID in the body parameter. Values in the body parameter override values in the query parameters. The download links in the response are valid for 8 hours.
8
 */
9
export async function main(
10
  auth: Shutterstock,
11
  subscription_id: string | undefined,
12
  format: "eps" | "jpg" | undefined,
13
  size: "small" | "medium" | "huge" | "vector" | "custom" | undefined,
14
  search_id: string | undefined,
15
  body: {
16
    images:
17
      | {
18
          auth_cookie?: { name: string; value: string };
19
          editorial_acknowledgement?: false | true;
20
          format?: "jpg";
21
          image_id: string;
22
          metadata?: {};
23
          price?: number;
24
          search_id?: string;
25
          show_modal?: false | true;
26
          size?: "small" | "medium" | "huge" | "custom";
27
          custom_dimensions?: { height?: number; width?: number };
28
          subscription_id?: string;
29
          verification_code?: string;
30
        }
31
      | {
32
          auth_cookie?: { name: string; value: string };
33
          editorial_acknowledgement?: false | true;
34
          format?: "eps";
35
          image_id: string;
36
          metadata?: {};
37
          price?: number;
38
          search_id?: string;
39
          show_modal?: false | true;
40
          size?: "vector";
41
          subscription_id?: string;
42
          verification_code?: string;
43
        }[];
44
  },
45
) {
46
  const url = new URL(`https://api.shutterstock.com/v2/images/licenses`);
47
  for (const [k, v] of [
48
    ["subscription_id", subscription_id],
49
    ["format", format],
50
    ["size", size],
51
    ["search_id", search_id],
52
  ]) {
53
    if (v !== undefined && v !== "" && k !== undefined) {
54
      url.searchParams.append(k, v);
55
    }
56
  }
57
  const response = await fetch(url, {
58
    method: "POST",
59
    headers: {
60
      "Content-Type": "application/json",
61
      Authorization: "Bearer " + auth.token,
62
    },
63
    body: JSON.stringify(body),
64
  });
65
  if (!response.ok) {
66
    const text = await response.text();
67
    throw new Error(`${response.status} ${text}`);
68
  }
69
  return await response.json();
70
}
71