0

Join queue

by
Published Oct 17, 2025

Join the queue for a restaurant.

Script yelp Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Yelp = {
3
  apiKey: string;
4
};
5
/**
6
 * Join queue
7
 * Join the queue for a restaurant.
8
 */
9
export async function main(
10
  auth: Yelp,
11
  business_id: string,
12
  body: {
13
    phone: string;
14
    party_size: number;
15
    name: string;
16
    seating_area_preference?: string;
17
    party_notes?: string;
18
    idempotency_token?: string;
19
  },
20
) {
21
  const url = new URL(
22
    `https://api.yelp.com/v3/businesses/${business_id}/waitlist/visits`,
23
  );
24

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