0

SearchTerminalActions

by
Published Oct 17, 2025

Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days.

Script square Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Square = {
3
  token: string;
4
};
5
/**
6
 * SearchTerminalActions
7
 * Retrieves a filtered list of Terminal action requests created by the account making the request. Terminal action requests are available for 30 days.
8
 */
9
export async function main(
10
  auth: Square,
11
  body: {
12
    query?: {
13
      filter?: {
14
        device_id?: string;
15
        created_at?: { start_at?: string; end_at?: string };
16
        status?: string;
17
        type?:
18
          | "QR_CODE"
19
          | "PING"
20
          | "SAVE_CARD"
21
          | "SIGNATURE"
22
          | "CONFIRMATION"
23
          | "RECEIPT"
24
          | "DATA_COLLECTION"
25
          | "SELECT";
26
      };
27
      sort?: { sort_order?: "DESC" | "ASC" };
28
    };
29
    cursor?: string;
30
    limit?: number;
31
  },
32
) {
33
  const url = new URL(
34
    `https://connect.squareup.com/v2/terminals/actions/search`,
35
  );
36

37
  const response = await fetch(url, {
38
    method: "POST",
39
    headers: {
40
      "Content-Type": "application/json",
41
      Authorization: "Bearer " + auth.token,
42
    },
43
    body: JSON.stringify(body),
44
  });
45
  if (!response.ok) {
46
    const text = await response.text();
47
    throw new Error(`${response.status} ${text}`);
48
  }
49
  return await response.json();
50
}
51