Identity

Who-am-I, organization membership, the live scope catalog, and OAuth2 token issuance/revocation.

GET/api/v1/me

Get the authenticated principal

Public — no scope required

Returns the user, active organization, role, raw token scopes, and effective permissions (token scopes ∩ role permissions). `organization.logoUrl` is a public, absolute image URL (it changes when the logo is replaced), or null when the business has not uploaded one.

Example request

curl "https://pre-invoice.avscorp.in/api/v1/me" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example response

JSON
{
  "user": {
    "id": "clx2usr001000000000000001",
    "email": "you@example.com",
    "name": "Karthik"
  },
  "organization": {
    "id": "clx2org001000000000000001",
    "name": "AVS Textiles",
    "slug": "avs-textiles",
    "logoUrl": "https://avsinvoice.app/api/org/logo/public/clx2org001000000000000001?v=1767225600000"
  },
  "role": "ADMIN",
  "tokenType": "oauth",
  "scopes": [
    "invoices",
    "paymentsReceived.read",
    "customers.read"
  ],
  "effectivePermissions": [
    "invoices.read",
    "invoices.create",
    "invoices.update",
    "invoices.delete",
    "paymentsReceived.read",
    "customers.read"
  ]
}

Possible errors: unauthorized

GET/api/v1/me/organizations

List the authenticated user's organizations

Public — no scope required

Bare array, not paginated — use for an organization switcher.

Example request

curl "https://pre-invoice.avscorp.in/api/v1/me/organizations" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example response

JSON
[
  {
    "id": "clx2org001000000000000001",
    "name": "AVS Textiles",
    "slug": "avs-textiles",
    "roleKey": "ADMIN"
  },
  {
    "id": "clx2org002000000000000001",
    "name": "Sunrise Apparel",
    "slug": "sunrise-apparel",
    "roleKey": "VIEWER"
  }
]

Possible errors: unauthorized

GET/api/v1/me/organization

Get the active organization's business profile

Public — no scope required

The seller info that appears on invoices: name, legal name, GSTIN, address, phone, email, state code, and base currency. Org-scoped via the token only — no request parameter.

Example request

curl "https://pre-invoice.avscorp.in/api/v1/me/organization" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example response

JSON
{
  "name": "AVS Textiles",
  "legalName": "AVS Textiles Private Limited",
  "gstin": "27AAAAA0000A1Z5",
  "address": "12 Industrial Estate, Sector 5, Navi Mumbai, 400701",
  "phone": "9876500000",
  "email": "accounts@avstextiles.in",
  "stateCode": "27",
  "currency": "INR"
}

Possible errors: unauthorized, not_found

GET/api/v1/me/subscription

Get the active organization's plan, trial and access mode

Public — no scope required

Any member. `accessMode` is FULL, READ_ONLY (trial ended or subscription suspended: writes get 402) or DISABLED, by the same rule as the paywall. `trialDaysLeft` rounds up and is 0 once the trial has ended. Paying is on the web at `billingUrl`, for members with `canManageBilling`.

Example request

curl "https://pre-invoice.avscorp.in/api/v1/me/subscription" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example response

JSON
{
  "plan": "PRO",
  "planName": "Pro",
  "status": "ACTIVE",
  "paid": false,
  "billingCycle": null,
  "isTrial": true,
  "trialEndsAt": "2026-11-08T10:00:00.000Z",
  "trialDaysLeft": 14,
  "renewsAt": null,
  "accessMode": "FULL",
  "canManageBilling": true,
  "billingUrl": "https://avsinvoice.app/settings/billing"
}

Possible errors: unauthorized

GET/api/v1/me/setup

Get the first-run setup wizard's state

Public — no scope required

Whether the active organization still needs setup (`pending`), whether this person should do it now (`canSetUp`: an owner or admin, on a writable org, as on the web), the draft to start from, and the states (`code` is what `stateCode` takes; `gstCode` is the GSTIN prefix).

Example request

curl "https://pre-invoice.avscorp.in/api/v1/me/setup" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example response

JSON
{
  "pending": true,
  "canSetUp": true,
  "draft": {
    "name": "Kaveri & Co.",
    "businessType": "",
    "gstRegistered": true,
    "gstin": "",
    "stateCode": "",
    "addressLine1": "",
    "addressLine2": "",
    "city": "",
    "pincode": "",
    "upiId": "",
    "bankName": "",
    "bankAccountNo": "",
    "bankIfscCode": "",
    "invoicePrefix": "INV",
    "layoutId": "standard",
    "modules": [
      "inventory",
      "purchases"
    ],
    "start": "fresh"
  },
  "states": [
    {
      "code": "TN",
      "name": "Tamil Nadu",
      "gstCode": "33"
    }
  ]
}

Possible errors: unauthorized, not_found

POST/api/v1/me/setup

Save the first-run setup wizard

Scope: settings.update

The web /setup wizard's rules and save, in one transaction: business, GST and address, UPI and bank, invoice prefix and design, modules. Clears setupPending. With `start: "sample"`, sample data is added too (`sampleAdded`); the setup is saved even if that fails. Field problems are 422 with `fields`.

Example request

curl -X POST "https://pre-invoice.avscorp.in/api/v1/me/setup" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Kaveri & Co.",
  "businessType": "TRADER",
  "gstRegistered": true,
  "gstin": "33AAPFU0939F1ZV",
  "stateCode": "TN",
  "addressLine1": "12 Main Rd",
  "addressLine2": "",
  "city": "Coimbatore",
  "pincode": "641001",
  "upiId": "kaveri@okhdfc",
  "bankName": "",
  "bankAccountNo": "",
  "bankIfscCode": "",
  "invoicePrefix": "INV",
  "layoutId": "standard",
  "modules": [
    "inventory",
    "purchases"
  ],
  "start": "fresh"
}'

Example response

JSON
{
  "done": true,
  "sampleAdded": false,
  "firstInvoiceNumber": "INV-00001",
  "importUrl": "https://avsinvoice.app/settings/import"
}

Possible errors: unauthorized, forbidden, insufficient_scope, validation_error, invalid_request, internal_error

POST/api/v1/me/setup/skip

Skip the first-run setup wizard

Scope: settings.update

"Skip setup for now": clears setupPending; the details can be filled in later in Settings.

Example request

curl -X POST "https://pre-invoice.avscorp.in/api/v1/me/setup/skip" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example response

JSON
{
  "skipped": true
}

Possible errors: unauthorized, forbidden, insufficient_scope

POST/api/v1/me/email-verification

Resend the confirm-your-email message

Public — no scope required

For the app's verify-email banner, shown while `GET /me` has `user.emailVerified: false`. Rate-limited per user (429).

Example request

curl -X POST "https://pre-invoice.avscorp.in/api/v1/me/email-verification" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example response

JSON
{
  "sentTo": "you@example.com"
}

Possible errors: unauthorized, validation_error, rate_limited

POST/api/v1/me/password

Change the signed-in user's password

Public — no scope required

First-party mobile app only: a personal access token or a third-party app gets 403. Checks `currentPassword`; `newPassword` needs at least 8 characters, must match `confirmPassword` and differ from the current one. Signs out every browser and every other app sign-in, keeps the calling app signed in, and emails the user a security notice. 10 attempts per 15 minutes per user (429). 409 when the account signs in only with Google and has no password.

Example request

curl -X POST "https://pre-invoice.avscorp.in/api/v1/me/password" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "currentPassword": "••••••••",
  "newPassword": "••••••••••",
  "confirmPassword": "••••••••••"
}'

Example response

JSON
{
  "passwordChangedAt": "2026-11-26T06:30:00.000Z"
}

Possible errors: unauthorized, forbidden, validation_error, conflict, rate_limited, invalid_request, internal_error

GET/api/v1/signup

Get whether signup is open, and the trial length

Public — no scope required

Public — no authentication required. For a signup screen's "14 days of Pro, free" line; `trialDays` is the master admin's current setting.

Example request

curl "https://pre-invoice.avscorp.in/api/v1/signup" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example response

JSON
{
  "enabled": true,
  "trialDays": 14,
  "plan": "PRO",
  "planName": "Pro"
}
POST/api/v1/signup

Create a user and their business on a trial

Public — no scope required

Public — first-party mobile app. The web signup's rules: a password of at least 8 characters, an email with no account yet, 5 attempts a minute per IP and per email. Then sign in with the password grant and the returned `organizationId`. 403 when signups are closed, 429 when rate-limited.

Example request

curl -X POST "https://pre-invoice.avscorp.in/api/v1/signup" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Priya",
  "email": "priya@example.com",
  "password": "••••••••••",
  "orgName": "Priya Traders"
}'

Example response

JSON
{
  "email": "priya@example.com",
  "organizationId": "clx…",
  "trialDays": 14
}

Possible errors: validation_error, forbidden, rate_limited, invalid_request, internal_error

POST/api/v1/me/organization/deletion

Start deleting the active organization (emails a code)

Scope: settings.delete

Owner only. Emails the owner a 6-digit code, valid for 10 minutes and 5 attempts; a new request replaces the previous code. The same flow as Settings › Danger zone on the web. Confirm with `POST /api/v1/me/organization/deletion/confirm`. `502 internal_error` when the email couldn't be sent.

Example request

curl -X POST "https://pre-invoice.avscorp.in/api/v1/me/organization/deletion" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example response

JSON
{
  "sentTo": "owner@example.com",
  "expiresInMinutes": 10
}

Possible errors: unauthorized, forbidden, insufficient_scope, validation_error, internal_error

POST/api/v1/me/organization/deletion/confirm

Permanently delete the active organization

Scope: settings.delete

Owner only, with the code from `POST /api/v1/me/organization/deletion`. Emails the owner a `.tar.gz` backup of every record, and only once that email is sent deletes the organization and all its data. Irreversible. Tokens for the organization stop working. A wrong, expired or used code is `422` with `fields.otp`; a failed backup email is `502` and nothing is deleted.

Example request

curl -X POST "https://pre-invoice.avscorp.in/api/v1/me/organization/deletion/confirm" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "otp": "123456"
}'

Example response

JSON
{
  "deleted": true
}

Possible errors: unauthorized, forbidden, insufficient_scope, validation_error, internal_error

GET/api/v1/scopes

Get the live scope catalog

Public — no scope required

Public — no authentication required. The authoritative, always-current list of group/module/granular scopes.

Example request

curl "https://pre-invoice.avscorp.in/api/v1/scopes" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example response

JSON
{
  "groups": [
    "read",
    "write",
    "full"
  ],
  "modules": [
    "customers",
    "quotes",
    "salesOrders",
    "invoices",
    "creditNotes",
    "recurringInvoices",
    "paymentsReceived",
    "collections",
    "salespersons",
    "schemes",
    "crm",
    "customerPortal",
    "vendors",
    "purchaseOrders",
    "bills",
    "debitNotes",
    "paymentsMade",
    "expenses",
    "items",
    "priceLists",
    "stock",
    "inventory",
    "challans",
    "manufacturing",
    "accounts",
    "taxes",
    "currencies",
    "paymentTerms",
    "numberSeries",
    "gstFiling",
    "gstReconciliation",
    "bankReconciliation",
    "reports",
    "salesReports",
    "purchaseReports",
    "inventoryReports",
    "financialReports",
    "approvals",
    "whatsapp",
    "settings",
    "users",
    "roles",
    "auditLog",
    "billing",
    "apiAccess",
    "dataImport"
  ],
  "granular": [
    "customers.read",
    "customers.create",
    "customers.update",
    "customers.delete",
    "customers.approve",
    "invoices.read",
    "invoices.create",
    "invoices.update",
    "invoices.delete"
  ]
}
GET/api/v1/app/android

Get the latest Android app release

Public — no scope required

Public — no authentication required. The app's update check: the latest APK's version and download link, and the oldest version still allowed to run. `data` is null when no release is configured on this server. Cached for 5 minutes.

Example request

curl "https://pre-invoice.avscorp.in/api/v1/app/android" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example response

JSON
{
  "latestVersionCode": 10100,
  "latestVersionName": "1.1.0",
  "minVersionCode": 10000,
  "apkUrl": "https://avsinvoice.app/downloads/avs-invoice-1.1.0.apk",
  "notes": "Sign in with Google."
}
POST/api/v1/oauth/token

Issue an OAuth2 token (authorization_code, password, google_id_token or refresh_token grant)

Public — no scope required

First-party mobile client only — the password grant means sending the end user's own credentials, which is not an appropriate pattern for a third-party integration. `grant_type=google_id_token` takes a Google `id_token` from native Google sign-in in place of username and password. Third-party apps use `grant_type=authorization_code` (with `code`, `redirect_uri`, `code_verifier`) after the consent screen, and get RFC 6749 error bodies; or a Personal Access Token (see Authentication). Response is the raw OAuth2 token payload, not the standard envelope.

Example request

curl -X POST "https://pre-invoice.avscorp.in/api/v1/oauth/token" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "grant_type": "password",
  "username": "you@example.com",
  "password": "••••••",
  "client_id": "avs-mobile",
  "scope": "invoices.read customers.read"
}'

Example response

JSON
{
  "access_token": "avs_at_9x7f2h1kQmZ...",
  "refresh_token": "avs_rt_3jf82hDkqLp...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "invoices.read paymentsReceived.read customers.read"
}

Possible errors: invalid_grant, invalid_client, unsupported_grant_type, invalid_request

POST/api/v1/oauth/register

Register an OAuth client (RFC 7591)

Public — no scope required

Dynamic client registration for MCP clients and other third-party apps. Open and rate-limited per IP. A registered client gets nothing until a member approves it on the consent screen (`/oauth/authorize`, authorization code + PKCE S256), and its tokens are capped by that member's role. Errors use the RFC shape `{ error, error_description }`, not the envelope.

Example request

curl -X POST "https://pre-invoice.avscorp.in/api/v1/oauth/register" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "client_name": "My MCP client",
  "redirect_uris": [
    "https://example.com/oauth/callback"
  ],
  "token_endpoint_auth_method": "none"
}'

Example response

JSON
{
  "client_id": "avs_mcp_Qm9zZXJ2ZXJfY2xpZW50XzAx",
  "client_id_issued_at": 1793289141,
  "client_name": "My MCP client",
  "redirect_uris": [
    "https://example.com/oauth/callback"
  ],
  "grant_types": [
    "authorization_code",
    "refresh_token"
  ],
  "response_types": [
    "code"
  ],
  "token_endpoint_auth_method": "none"
}

Possible errors: invalid_request, rate_limited

POST/api/v1/oauth/revoke

Revoke an OAuth2 access or refresh token

Public — no scope required

Always returns 200 regardless of whether the token existed (RFC 7009 semantics). Response is not the standard envelope.

Example request

curl -X POST "https://pre-invoice.avscorp.in/api/v1/oauth/revoke" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "token": "avs_at_9x7f2h1kQmZ..."
}'

Example response

JSON
{
  "success": true
}