0

BulkCreateCustomers

by
Published Oct 17, 2025

Creates multiple [customer profiles]($m/Customer) for a business. This endpoint takes a map of individual create requests and returns a map of responses. You must provide at least one of the following values in each create request: - `given_name` - `family_name` - `company_name` - `email_address` - `phone_number`

Script square Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Square = {
3
  token: string;
4
};
5
/**
6
 * BulkCreateCustomers
7
 * Creates multiple [customer profiles]($m/Customer) for a business.
8

9
This endpoint takes a map of individual create requests and returns a map of responses.
10

11
You must provide at least one of the following values in each create request:
12

13
- `given_name`
14
- `family_name`
15
- `company_name`
16
- `email_address`
17
- `phone_number`
18
 */
19
export async function main(auth: Square, body: { customers: {} }) {
20
  const url = new URL(`https://connect.squareup.com/v2/customers/bulk-create`);
21

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