Every module for ₹9 per employee. Hosting and security included. No sales calls. Every module, ₹9 per employee Pricing →

Sign in Get started

Developers / Recipes

Integration recipes

The integrations companies ask for most, as a few API calls each. Run any of them in your sandbox, step by step, then copy the finished script. With a sandbox on, the scripts below already hold your key and sample ids.

Recipe 1

Feed your payroll every month

Wait for HR to lock the month, then read paid days, LOP and expenses to pay.

  1. Subscribe to the event HR’s lock sends.

    POST/v1/webhooks
    {
      "url": "inbox",
      "events": [
        "payroll.month.locked"
      ],
      "description": "Payroll"
    }
  2. See which months are locked.

    GET/v1/payroll/months
  3. Read a locked month. Each person’s paid days and LOP are ready for your salary run.

    GET/v1/payroll/months/{month}

Run it in your sandbox

The complete script

// Feed your payroll every month: an ANOMA API recipe.
// Wait for HR to lock the month, then read paid days, LOP and expenses to pay.
// Run it with Node 18 or later:  ANOMA_KEY=ank_… node payroll.mjs

const API = 'https://app.anomahq.com/api';
const KEY = process.env.ANOMA_KEY || '__KEY__';

async function anoma(method, path, body) {
  const res = await fetch(API + path, {
    method,
    headers: { Authorization: `Bearer ${KEY}`, ...(body ? { 'Content-Type': 'application/json' } : {}) },
    body: body ? JSON.stringify(body) : undefined,
  });
  const data = await res.json();
  if (!res.ok) throw new Error(`${method} ${path}: ${res.status} ${data.error?.message} (request ${res.headers.get('x-request-id')})`);
  return data;
}

// 1. Subscribe to the event HR’s lock sends.
const step1 = await anoma('POST', '/v1/webhooks', { url: 'inbox', events: ['payroll.month.locked'], description: 'Payroll' });
console.log('1.', step1);

// 2. See which months are locked.
const step2 = await anoma('GET', '/v1/payroll/months');
console.log('2.', step2);

// 3. Read a locked month. Each person’s paid days and LOP are ready for your salary run.
if (!step2.data.length) throw new Error('No month is locked yet. HR locks one in ANOMA: Close the month for payroll.');
const step3 = await anoma('GET', `/v1/payroll/months/${step2.data[0].month}`);
console.log('3.', step3);
Recipe 2

Keep another system’s people in step

Copy everyone once, then apply changes as they happen.

  1. Copy everyone (page through with after=next_cursor).

    GET/v1/employees?limit=5
  2. Subscribe to joins, changes and exits.

    POST/v1/webhooks
    {
      "url": "inbox",
      "events": [
        "employee.created",
        "employee.updated",
        "employee.exited"
      ]
    }
  3. Add someone, and watch employee.created arrive.

    POST/v1/employees
    {
      "first_name": "Arjun",
      "last_name": "Mehta",
      "email": "arjun.{rand}@sandbox.test",
      "join_date": "{today}",
      "designation": "Sales executive"
    }

Run it in your sandbox

The complete script

// Keep another system’s people in step: an ANOMA API recipe.
// Copy everyone once, then apply changes as they happen.
// Run it with Node 18 or later:  ANOMA_KEY=ank_… node directory.mjs

const API = 'https://app.anomahq.com/api';
const KEY = process.env.ANOMA_KEY || '__KEY__';
const today = new Date().toLocaleDateString('en-CA'); // YYYY-MM-DD
const rand = Math.random().toString(36).slice(2, 8);

async function anoma(method, path, body) {
  const res = await fetch(API + path, {
    method,
    headers: { Authorization: `Bearer ${KEY}`, ...(body ? { 'Content-Type': 'application/json' } : {}) },
    body: body ? JSON.stringify(body) : undefined,
  });
  const data = await res.json();
  if (!res.ok) throw new Error(`${method} ${path}: ${res.status} ${data.error?.message} (request ${res.headers.get('x-request-id')})`);
  return data;
}

// 1. Copy everyone (page through with after=next_cursor).
const step1 = await anoma('GET', '/v1/employees?limit=5');
console.log('1.', step1);

// 2. Subscribe to joins, changes and exits.
const step2 = await anoma('POST', '/v1/webhooks', {
  url: 'inbox',
  events: ['employee.created', 'employee.updated', 'employee.exited'],
});
console.log('2.', step2);

// 3. Add someone, and watch employee.created arrive.
const step3 = await anoma('POST', '/v1/employees', {
  first_name: 'Arjun',
  last_name: 'Mehta',
  email: `arjun.${rand}@sandbox.test`,
  join_date: today,
  designation: 'Sales executive',
});
console.log('3.', step3);
Recipe 3

Time off from your own app

Request leave from your intranet or bot, and follow it through approval.

  1. Subscribe to every leave event.

    POST/v1/webhooks
    {
      "url": "inbox",
      "events": [
        "leave.submitted",
        "leave.approved",
        "leave.rejected"
      ]
    }
  2. Pick a person and a leave type.

    GET/v1/leave/types
  3. Request time off. leave.submitted fires.

    POST/v1/leave/requests
    {
      "employee_id": "{employee_id}",
      "leave_type_id": "{leave_type_id}",
      "start_date": "{in_14_days}",
      "end_date": "{in_15_days}",
      "reason": "Sent from my app"
    }
  4. Approve it as HR. leave.approved fires.

    POST/v1/approvals/leave/{leave_id}/decide
    {
      "decision": "approved"
    }

Run it in your sandbox

The complete script

// Time off from your own app: an ANOMA API recipe.
// Request leave from your intranet or bot, and follow it through approval.
// Run it with Node 18 or later:  ANOMA_KEY=ank_… node leave.mjs

const API = 'https://app.anomahq.com/api';
const KEY = process.env.ANOMA_KEY || '__KEY__';
const EMPLOYEE_ID = __EMPLOYEE_ID__; // someone in your company
const LEAVE_TYPE_ID = __LEAVE_TYPE_ID__; // from GET /v1/leave/types
const weekday = n => { const d = new Date(Date.now() + n * 864e5); while ([0, 6].includes(d.getDay())) d.setDate(d.getDate() + 1); return d.toLocaleDateString('en-CA'); };

async function anoma(method, path, body) {
  const res = await fetch(API + path, {
    method,
    headers: { Authorization: `Bearer ${KEY}`, ...(body ? { 'Content-Type': 'application/json' } : {}) },
    body: body ? JSON.stringify(body) : undefined,
  });
  const data = await res.json();
  if (!res.ok) throw new Error(`${method} ${path}: ${res.status} ${data.error?.message} (request ${res.headers.get('x-request-id')})`);
  return data;
}

// 1. Subscribe to every leave event.
const step1 = await anoma('POST', '/v1/webhooks', {
  url: 'inbox',
  events: ['leave.submitted', 'leave.approved', 'leave.rejected'],
});
console.log('1.', step1);

// 2. Pick a person and a leave type.
const step2 = await anoma('GET', '/v1/leave/types');
console.log('2.', step2);

// 3. Request time off. leave.submitted fires.
const step3 = await anoma('POST', '/v1/leave/requests', {
  employee_id: EMPLOYEE_ID,
  leave_type_id: LEAVE_TYPE_ID,
  start_date: weekday(14),
  end_date: weekday(15),
  reason: 'Sent from my app',
});
console.log('3.', step3);

// 4. Approve it as HR. leave.approved fires.
const step4 = await anoma('POST', `/v1/approvals/leave/${step3.id}/decide`, { decision: 'approved' });
console.log('4.', step4);
Recipe 4

Connect a punch machine

Send punches from your device software; ANOMA turns them into attendance.

  1. Send a day’s punches by employee code.

    POST/v1/attendance/punches
    {
      "punches": [
        {
          "emp_code": "{emp_code}",
          "at": "{today}T09:05"
        },
        {
          "emp_code": "{emp_code}",
          "at": "{today}T18:20"
        }
      ]
    }
  2. Read the attendance it made.

    GET/v1/attendance?from={today}&to={today}

Run it in your sandbox

The complete script

// Connect a punch machine: an ANOMA API recipe.
// Send punches from your device software; ANOMA turns them into attendance.
// Run it with Node 18 or later:  ANOMA_KEY=ank_… node punches.mjs

const API = 'https://app.anomahq.com/api';
const KEY = process.env.ANOMA_KEY || '__KEY__';
const EMP_CODE = '__EMP_CODE__'; // the employee code on the punch machine
const today = new Date().toLocaleDateString('en-CA'); // YYYY-MM-DD

async function anoma(method, path, body) {
  const res = await fetch(API + path, {
    method,
    headers: { Authorization: `Bearer ${KEY}`, ...(body ? { 'Content-Type': 'application/json' } : {}) },
    body: body ? JSON.stringify(body) : undefined,
  });
  const data = await res.json();
  if (!res.ok) throw new Error(`${method} ${path}: ${res.status} ${data.error?.message} (request ${res.headers.get('x-request-id')})`);
  return data;
}

// 1. Send a day’s punches by employee code.
const step1 = await anoma('POST', '/v1/attendance/punches', {
  punches: [
    { emp_code: EMP_CODE, at: `${today}T09:05` },
    { emp_code: EMP_CODE, at: `${today}T18:20` },
  ],
});
console.log('1.', step1);

// 2. Read the attendance it made.
const step2 = await anoma('GET', `/v1/attendance?from=${today}&to=${today}`);
console.log('2.', step2);