0

SearchTerminalCheckouts

by
Published Oct 17, 2025

Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout 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
 * SearchTerminalCheckouts
7
 * Returns a filtered list of Terminal checkout requests created by the application making the request. Only Terminal checkout requests created for the merchant scoped to the OAuth token are returned. Terminal checkout 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
      };
18
      sort?: { sort_order?: "DESC" | "ASC" };
19
    };
20
    cursor?: string;
21
    limit?: number;
22
  },
23
) {
24
  const url = new URL(
25
    `https://connect.squareup.com/v2/terminals/checkouts/search`,
26
  );
27

28
  const response = await fetch(url, {
29
    method: "POST",
30
    headers: {
31
      "Content-Type": "application/json",
32
      Authorization: "Bearer " + auth.token,
33
    },
34
    body: JSON.stringify(body),
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.json();
41
}
42