0

License videos

by
Published Oct 17, 2025

This endpoint gets licenses for one or more videos. You must specify the video IDs in the body parameter and the size and subscription ID either in the query parameter or with each video 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 videos
7
 * This endpoint gets licenses for one or more videos. You must specify the video IDs in the body parameter and the size and subscription ID either in the query parameter or with each video 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
  size: "web" | "sd" | "hd" | "4k" | undefined,
13
  search_id: string | undefined,
14
  body: {
15
    videos: {
16
      auth_cookie?: { name: string; value: string };
17
      editorial_acknowledgement?: false | true;
18
      metadata?: {};
19
      price?: number;
20
      search_id?: string;
21
      show_modal?: false | true;
22
      size?: "web" | "sd" | "hd" | "4k";
23
      subscription_id?: string;
24
      video_id: string;
25
    }[];
26
  },
27
) {
28
  const url = new URL(`https://api.shutterstock.com/v2/videos/licenses`);
29
  for (const [k, v] of [
30
    ["subscription_id", subscription_id],
31
    ["size", size],
32
    ["search_id", search_id],
33
  ]) {
34
    if (v !== undefined && v !== "" && k !== undefined) {
35
      url.searchParams.append(k, v);
36
    }
37
  }
38
  const response = await fetch(url, {
39
    method: "POST",
40
    headers: {
41
      "Content-Type": "application/json",
42
      Authorization: "Bearer " + auth.token,
43
    },
44
    body: JSON.stringify(body),
45
  });
46
  if (!response.ok) {
47
    const text = await response.text();
48
    throw new Error(`${response.status} ${text}`);
49
  }
50
  return await response.json();
51
}
52