openapi: 3.1.0
info:
  title: USR One API
  version: "v2.1 · 23 Nov 2026"
  description: "Live = works today. Sandbox = works on https://train.usrinfo.tech with usrk_ keys and sample data; USR One production coming soon. Docs: https://usrinfo.tech/developers/"
servers:
  - url: https://train.usrinfo.tech
    description: Sandbox (sample data)
  - url: https://apps.usrinfo.tech
    description: USR One production (coming soon)
components:
  securitySchemes:
    bearer: {type: http, scheme: bearer}
security:
  - bearer: []
paths:
  /api/v1/hris/employees:
    get:
      operationId: emp_list
      tags: ["People: HRIS"]
      summary: "List employees [Sandbox]"
      description: "Every employee in the company, with department, designation, manager and status. Scope: people:read."
      x-usr-status: Sandbox
      parameters:
        - name: page
          in: query
          required: false
          schema: {type: string}
          description: "Page number, from 0"
        - name: size
          in: query
          required: false
          schema: {type: string}
          description: "Items per page, up to 200"
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": {"content": [{"id": "6f1c…", "code": "E-1093", "name": "Priya N.", "managerId": "a21b…", "department": "Sales", "designation": "Executive", "grade": "G3", "status": "ACTIVE", "dateOfJoining": "2026-04-01", "dateOfLeaving": null, "city": "Bengaluru", "state": "Karnataka"}]}, "message": null, "errorCode": null, "timestamp": "2026-11-18T10:00:00Z"}
    post:
      operationId: emp_create
      tags: ["People: HRIS"]
      summary: "Create an employee [Sandbox]"
      description: "Adds an employee once; HRMS, payroll, PMS and LMS read the same record. Code: up to 32 letters, digits, dashes, slashes or underscores. Scope: people:write."
      x-usr-status: Sandbox
      requestBody:
        content:
          application/json:
            example: {"code": "E-1094", "name": "Rahul S.", "email": "rahul@example.com", "dateOfJoining": "2026-12-01"}
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": {"id": "9d2e…", "code": "E-1094", "name": "Rahul S.", "status": "ACTIVE"}}
  /api/v1/hris/employees/{id}:
    get:
      operationId: emp_get
      tags: ["People: HRIS"]
      summary: "Get one employee [Sandbox]"
      description: "Full employee record: contact, department, designation, manager, location and employment type. Scope: people:read."
      x-usr-status: Sandbox
      parameters:
        - name: id
          in: path
          required: true
          schema: {type: string}
          description: "Employee id"
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": {"id": "6f1c…", "code": "E-1093", "name": "Priya N.", "email": "priya@example.com", "department": {"id": "…", "name": "Sales"}, "designation": {"id": "…", "name": "Executive"}, "manager": {"id": "…", "name": "Arjun K."}, "employmentType": "FULL_TIME", "status": "ACTIVE"}}
  /api/v1/hrms/attendance:
    get:
      operationId: att_list
      tags: ["People: HRMS"]
      summary: "Attendance by employee and dates [Sandbox]"
      description: "Daily status, in and out times, overtime and source (biometric, app, regularised). Scope: attendance:read."
      x-usr-status: Sandbox
      parameters:
        - name: employeeId
          in: query
          required: false
          schema: {type: string}
          description: "Employee"
        - name: from
          in: query
          required: false
          schema: {type: string}
          description: "YYYY-MM-DD"
        - name: to
          in: query
          required: false
          schema: {type: string}
          description: "YYYY-MM-DD"
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": [{"id": "…", "employee": {"id": "6f1c…", "name": "Priya N."}, "date": "2026-11-17", "status": "PRESENT", "inTime": "09:32", "outTime": "18:41", "source": "BIOMETRIC", "otHours": 0.5}]}
  /api/v1/hrms/attendance/punch:
    post:
      operationId: att_punch
      tags: ["People: HRMS"]
      summary: "Send a punch (biometric or app) [Sandbox]"
      description: "For biometric devices and attendance apps: one punch in or out. Scope: attendance:write."
      x-usr-status: Sandbox
      requestBody:
        content:
          application/json:
            example: {"employeeId": "6f1c…", "at": "2026-11-18T09:31:00+05:30"}
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": {"date": "2026-11-18", "inTime": "09:31"}}
  /api/v1/hrms/leave-requests:
    get:
      operationId: leave_list
      tags: ["People: HRMS"]
      summary: "List leave requests [Sandbox]"
      description: "Leave requests with type, dates and approval status. Scope: leave:read."
      x-usr-status: Sandbox
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": [{"id": "…", "employee": {"name": "Priya N."}, "leaveType": "CL", "from": "2026-11-24", "to": "2026-11-25", "status": "APPROVED"}]}
  /api/v1/hrms/payroll-runs:
    post:
      operationId: pay_run
      tags: ["People: Payroll"]
      summary: "Start a payroll run [Sandbox]"
      description: "Creates the run for a month from attendance, leave and salary structures. Scope: payroll:write."
      x-usr-status: Sandbox
      requestBody:
        content:
          application/json:
            example: {"month": "2026-11"}
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": {"id": "r_31…", "month": "2026-11", "status": "DRAFT", "employees": 64}}
  /api/v1/hrms/payroll-runs/{id}:
    get:
      operationId: pay_get
      tags: ["People: Payroll"]
      summary: "Get a payroll run [Sandbox]"
      description: "Totals for gross, net, TDS and employer cost, and who processed and paid it. Scope: payroll:read."
      x-usr-status: Sandbox
      parameters:
        - name: id
          in: path
          required: true
          schema: {type: string}
          description: "Run id"
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": {"id": "r_31…", "month": "2026-11", "status": "PROCESSED", "employees": 64, "totalGross": 3120000.0, "totalNet": 2786400.0, "totalTds": 141200.0, "totalCost": 3410500.0}}
  /api/v1/hrms/payroll-runs/{id}/payslips:
    get:
      operationId: payslips
      tags: ["People: Payroll"]
      summary: "Payslips of a run [Sandbox]"
      description: "One payslip per employee: paid days, loss of pay, gross, deductions and net pay. Scope: payroll:read."
      x-usr-status: Sandbox
      parameters:
        - name: id
          in: path
          required: true
          schema: {type: string}
          description: "Run id"
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": [{"id": "…", "month": "2026-11", "employee": {"name": "Priya N."}, "paidDays": 30, "lopDays": 0, "gross": 48000.0, "totalDeductions": 4310.0, "netPay": 43690.0}]}
  /api/v1/billing/invoices:
    get:
      operationId: bill_inv
      tags: ["Sales: Billing"]
      summary: "List customer invoices [Sandbox]"
      description: "Invoices raised to your customers, with payments received. Scope: billing:read."
      x-usr-status: Sandbox
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": [{"id": "…", "number": "INV-2207", "customer": {"name": "Sharma Traders"}, "total": 141600.0, "status": "PAID"}]}
  /api/v1/billing/invoices/{id}/payments:
    post:
      operationId: bill_payment
      tags: ["Sales: Billing"]
      summary: "Record a payment [Sandbox]"
      description: "Marks money received against an invoice, for example from your payment gateway. Scope: billing:write."
      x-usr-status: Sandbox
      parameters:
        - name: id
          in: path
          required: true
          schema: {type: string}
          description: "Invoice id"
      requestBody:
        content:
          application/json:
            example: {"amount": 141600.0, "date": "2026-11-18", "mode": "UPI", "reference": "UTR 4321…"}
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": {"balance": 0.0}}
  /api/v1/books/invoices:
    post:
      operationId: books_inv
      tags: ["Finance: Books"]
      summary: "Create a GST invoice in Books [Sandbox]"
      description: "GST split (CGST, SGST or IGST) is worked out from the place of supply. Scope: finance:write."
      x-usr-status: Sandbox
      requestBody:
        content:
          application/json:
            example: {"customerId": "c_12…", "date": "2026-11-18", "creditDays": 30, "gstRate": 18, "lines": [{"description": "Annual subscription", "hsn": "998314", "quantity": 1, "rate": 120000}]}
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": {"number": "INV-3381", "taxable": 120000.0, "cgst": 10800.0, "sgst": 10800.0, "igst": 0, "total": 141600.0}}
  /api/v1/books/journals:
    post:
      operationId: books_jv
      tags: ["Finance: Books"]
      summary: "Post a journal [Sandbox]"
      description: "Debits must equal credits. Up to 50 lines, amounts in rupees and paise. Scope: finance:write."
      x-usr-status: Sandbox
      requestBody:
        content:
          application/json:
            example: {"date": "2026-11-18", "narration": "Bank charges", "lines": [{"accountCode": "6100", "debit": 250.0}, {"accountCode": "1200", "credit": 250.0}]}
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": {"number": "JV-0412", "totalDebit": 250.0, "totalCredit": 250.0}}
  /api/v1/books/reports/trial-balance:
    get:
      operationId: books_tb
      tags: ["Finance: Books"]
      summary: "Trial balance [Sandbox]"
      description: "Balances by account for a date range, for your CA or reporting tool. Scope: finance:read."
      x-usr-status: Sandbox
      parameters:
        - name: from
          in: query
          required: false
          schema: {type: string}
          description: "YYYY-MM-DD"
        - name: to
          in: query
          required: false
          schema: {type: string}
          description: "YYYY-MM-DD"
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"success": true, "data": {"rows": [{"accountCode": "1200", "accountName": "Bank", "debit": 845000.0, "credit": 0}]}}
  /api/tally/bridge/jobs:
    get:
      operationId: tally_jobs
      tags: ["Connect: TallyPrime"]
      summary: "Bridge: collect jobs for Tally [Live]"
      description: "Used by the USR Tally Bridge on the Tally PC. It asks every 10 seconds over HTTPS (outbound only) and runs each job against TallyPrime on localhost:9000. The company admin creates the key on the Connections page; USR keeps only its hash. Scope: Tally bridge key."
      x-usr-status: Live
      parameters:
        - name: Authorization
          in: header
          required: false
          schema: {type: string}
          description: "Bearer usrtb_\u2026"
        - name: X-Bridge-Version
          in: header
          required: false
          schema: {type: string}
          description: "e.g. 1.1"
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"jobs": [{"id": "0c9e…", "kind": "voucher", "xml": "<ENVELOPE>…</ENVELOPE>", "check": {"type": "Sales", "number": "INV-3381", "date": "20261118", "tag": "[USR:books:INV-3381]"}}]}
  /api/tally/bridge/jobs/{id}:
    post:
      operationId: tally_result
      tags: ["Connect: TallyPrime"]
      summary: "Bridge: send Tally's answer [Live]"
      description: "The bridge sends back what Tally answered. A voucher already in Tally is never posted twice. Scope: Tally bridge key."
      x-usr-status: Live
      parameters:
        - name: id
          in: path
          required: true
          schema: {type: string}
          description: "Job id"
      requestBody:
        content:
          application/json:
            example: {"ok": true, "result": "<RESPONSE>…</RESPONSE>"}
      responses:
        '200':
          description: OK
          content:
            application/json:
              example: {"ok": true}
