HR Attendance System

API Documentation

How to use the QR code webhook endpoint

Webhook Endpoint
The webhook endpoint receives data from QR code scans

Endpoint URL

https://your-app.vercel.app/api/webhook

Method

GET

Query Parameters

  • name - The person's full name
  • email - The person's email address
  • phone - The person's phone number

Example Request

GET /api/webhook?name=John+Doe&email=john@example.com&phone=123456789

Response

{
  "success": true,
  "message": "Data successfully written to Google Sheet",
  "data": {
    "name": "John Doe",
    "email": "john@example.com",
    "phone": "123456789"
  }
}
Google Sheets Integration
How to set up the Google Sheets integration

Required Environment Variables

  • GOOGLE_SHEET_ID - The ID of your Google Sheet
  • GOOGLE_CLIENT_EMAIL - The client email from your Google service account
  • GOOGLE_PRIVATE_KEY - The private key from your Google service account

Setting Up Google Service Account

  1. Go to the Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the Google Sheets API
  4. Create a service account
  5. Create a key for the service account (JSON format)
  6. Share your Google Sheet with the service account email
Alternative: Google Apps Script
If you prefer to use Google Apps Script instead

You can also use Google Apps Script as described in your original plan. Here's the code:

const SHEET_NAME = "Sheet1"; // Change to your sheet name

function doGet(e) {
  const name = e.parameter.name;
  const email = e.parameter.email;
  const phone = e.parameter.phone;

  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(SHEET_NAME);

  sheet.appendRow([new Date(), name, email, phone]);

  return ContentService.createTextOutput("Received! Thank you.");
}

Steps to Deploy

  1. In Google Sheets: Extensions > Apps Script
  2. Paste the code above
  3. Save the project
  4. Deploy > New deployment
  5. Select type: Web app
  6. Set "Who has access" to "Anyone"
  7. Deploy and copy the web app URL