Auto Upi API documentation

Create an order from your server and open the hosted checkout as a popup on your own website. Orders are confirmed automatically through your Paytm account — money goes straight into your UPI ID.

Base URL

https://pg.autoupi.in/api/public/v1

Format

application/json

Auth header

X-API-Key

Integrate with any AI in minutes

Download one text file with the complete A to Z guide. Give it to ChatGPT, Claude, Cursor or any AI — it asks only for your keys and writes the integration for your website.

AI Integration

Overview

Every payment follows the same four steps. Your API key never leaves your server, and only Auto Upi's server can mark an order paid.

  1. 1

    Create order

    Your server calls create-order with the amount.

  2. 2

    Open popup

    Your page calls AutoUpi.open(payment_url).

  3. 3

    Customer pays

    Scan the QR with any UPI app. Checked every 3 seconds.

  4. 4

    Confirm

    Signed webhook or order-status says paid. Fulfil once.

Quickstart

  1. Create an account and sign in to the dashboard.
  2. Connect your Paytm account — save your Paytm MID, UPI ID, business name and logo on the Settings page.
  3. Generate an API key on the API Keys page. Copy it once; regenerating replaces the old key.
  4. Copy the webhook secret from API Keys and store both credentials securely on your server.
  5. Set your webhook URL on Settings, or pass your HTTPS webhook endpoint when creating each order.
  6. Load the popup script once from https://pg.autoupi.in/checkout.js.
  7. Create an order from your server, save its ID against the buyer, then call AutoUpi.open({ url: payment_url }) on your page. See Popup checkout.
  8. Confirm payment through your signed webhook or a server-side status check, then update the same page and fulfil the order once.

Authentication

Every request carries your secret key in the X-API-Key header. Keys start with aupi_live_ and are stored hashed — an old key can never be shown again. Call the API only from your server; never expose the key in browser code.

header
X-API-Key: aupi_live_xxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json

Create order

POST/api/public/v1/create-order

FieldTypeRequiredDescription
amountnumberYesOrder amount in INR, 1 to 1,00,000 (up to 2 decimals).
customer_namestringNoShown in your passbook and sent back in the webhook.
webhook_urlstringNoHTTPS URL that receives the signed payment.paid webhook.
link_typestringNoone_time (default). Each order can be paid once.
curl -X POST https://pg.autoupi.in/api/public/v1/create-order \
  -H "X-API-Key: aupi_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{"amount": 1499, "customer_name": "Rahul Sharma", "webhook_url": "https://yoursite.com/autoupi-webhook.php"}'

200 response

json
{
  "ok": true,
  "order_id": "ORDK7Q2M9X4B1ZP",
  "customer_name": "Rahul Sharma",
  "amount": 1499,
  "payable_amount": 1499,
  "status": "active",
  "paid_at": null,
  "created_at": "2026-09-15T10:21:00.000Z",
  "expires_at": "2026-09-15T10:26:00.000Z",
  "payment_url": "https://pg.autoupi.in/pay/ORDK7Q2M9X4B1ZP"
}

Order IDs are always 15 characters: ORD followed by 12 random capital letters and digits, unique for every order. payable_amount always equals amount.

Order status

GET/api/public/v1/order-status?order_id=ORD…

Check this endpoint from your server during checkout or after a popup callback to confirm payment before fulfilment. Your page calls your own status endpoint; it never sends the API key directly.

curl "https://pg.autoupi.in/api/public/v1/order-status?order_id=ORDK7Q2M9X4B1ZP" \
  -H "X-API-Key: aupi_live_your_key"

200 response

json
{
  "ok": true,
  "order": {
    "order_id": "ORDK7Q2M9X4B1ZP",
    "customer_name": "Rahul Sharma",
    "amount": 1499,
    "payable_amount": 1499,
    "status": "paid",
    "paid_at": "2026-09-15T10:21:44.120Z",
    "created_at": "2026-09-15T10:21:00.000Z",
    "expires_at": "2026-09-15T10:26:00.000Z"
  }
}
StatusMeaning
activeWaiting for payment. Links expire 5 minutes after creation.
paidPaytm confirmed the payment for this order and amount. Safe to fulfil.
expiredNo payment detected in time. Create a new order.

Webhooks

Each API key ships with a webhook secret (whsec_…) shown on the API Keys page. Pass a webhook_url when creating an order and we POST a signed payment.paid event the moment the order is confirmed as paid. You can also save one default webhook URL on the Settings page — it is used for every order of your account when the create order call does not send its own webhook_url.

payload
POST https://yoursite.com/autoupi-webhook.php
X-AutoUpi-Signature: t=1789453200,v1=6f3c…9ab

{
  "event": "payment.paid",
  "order_id": "ORDK7Q2M9X4B1ZP",
  "amount": 1499,
  "payable_amount": 1499,
  "status": "paid",
  "customer_name": "Rahul Sharma",
  "paid_at": "2026-09-15T10:21:44.120Z"
}

signed_payload = "{t}." + raw_request_body
v1 = hex(hmac_sha256(webhook_secret, signed_payload))
<?php
// autoupi-webhook.php
$secret = getenv("AUTOUPI_WEBHOOK_SECRET");
$raw    = file_get_contents("php://input");
$header = $_SERVER["HTTP_X_AUTOUPI_SIGNATURE"] ?? "";

parse_str(str_replace(",", "&", $header), $parts);   // t=..., v1=...
$expected = hash_hmac("sha256", ($parts["t"] ?? "") . "." . $raw, $secret);

if (!hash_equals($expected, $parts["v1"] ?? "")) {
  http_response_code(401);
  exit("bad signature");
}

$event = json_decode($raw, true);
if ($event["event"] === "payment.paid") {
  // idempotent: skip if this order_id is already fulfilled
  mark_order_paid($event["order_id"], $event["amount"]);
}
http_response_code(200);
echo "ok";

Always treat delivery as at-least-once and keep your handler idempotent.

Keep the customer on your own website. Load our script once, create the order on your server as usual, then open the returned payment_url as a popup. The same payment page opens on top of your page and closes by itself after the result.

HTML / JavaScript
<script src="https://pg.autoupi.in/checkout.js"></script>
<button id="pay">Pay now</button>
<p id="payment-status" role="status"></p>
<script>
  const payButton = document.getElementById("pay");
  const paymentStatus = document.getElementById("payment-status");
  payButton.onclick = async () => {
    payButton.disabled = true;
    paymentStatus.textContent = "Starting payment…";
    try {
      // Your server uses the saved cart price, not a browser-supplied amount.
      // Protect this request with your app's session and CSRF controls.
      const response = await fetch("/checkout.php", { method: "POST" });
      const order = await response.json();
      if (!response.ok || !order.ok || !order.payment_url) {
        throw new Error("Could not start payment. Please try again.");
      }
      if (!window.AutoUpi) throw new Error("Checkout could not load. Please try again.");
      AutoUpi.open({
        url: order.payment_url,
        onSuccess: (result) => {
          paymentStatus.textContent = "Confirming payment…";
          // Call YOUR server's buyer-scoped order-status endpoint here.
          // Show success only after it reads paid from the API.
          payButton.disabled = false;
        },
        onFailure: (result) => {
          paymentStatus.textContent = "Payment failed or expired. Please try again.";
          payButton.disabled = false;
        },
      });
      paymentStatus.textContent = "Waiting for payment…";
    } catch (error) {
      paymentStatus.textContent = error.message || "Could not start payment.";
      payButton.disabled = false;
    }
  };
</script>

Server-side order creation

php
<?php
$ch = curl_init("https://pg.autoupi.in/api/public/v1/create-order");
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => ["Content-Type: application/json", "X-API-Key: " . getenv("AUTOUPI_KEY")],
  // Example price only: use your server's saved cart amount in production.
  CURLOPT_POSTFIELDS => json_encode(["amount" => 100, "webhook_url" => "https://yoursite.com/autoupi-webhook.php"]),
]);
// For complete order saving and error handling, see checkout.php below.
header("Content-Type: application/json");
echo curl_exec($ch);

The popup result only updates your screen. Deliver the product only after the signed webhook (or the order status API) says the order is paid. Update the current merchant page after confirmation; do not navigate the customer away.

Popup size and setup checklist

  • Desktop: up to 860px wide and 520px high, limited to 94% of screen width and 80% of screen height.
  • Mobile: 94% of screen width and 80% of the visible screen height. Short screens scroll inside the checkout.
  • The script adds the 3px border, rounded corners and backdrop. There is no top-right close icon; the left Back control asks before exiting.
  • Load the hosted script once and call AutoUpi.open directly with the returned payment_url. Do not self-host a copy.
  • Allow https://pg.autoupi.in in your site's script-src and frame-src policies if you use Content Security Policy.
  • Keep API keys and webhook secrets on your server.
  • Use onSuccess and onFailure for result updates. Results: onSuccess({ order_id, status: "paid" }), onFailure({ order_id, status: "failed" }); leaving with Back → Yes calls onFailure with status cancelled.
  • Check one paid order, one expired order, duplicate webhook delivery and the Back confirmation on desktop and mobile before going live.

PHP integration in 3 files

Use these three server-side files with the HTML / JavaScript popup example above. Connect the order-saving and fulfilment hooks to your existing site. WordPress, Laravel and CodeIgniter should use their own session, CSRF and request handling conventions.

1. autoupi.php — tiny helper class

autoupi.php
<?php
class AutoUpi {
  private string $key;
  private string $base;

  public function __construct(string $key, string $base = "https://pg.autoupi.in/api/public/v1") {
    $this->key = $key;
    $this->base = $base;
  }

  private function request(string $url, ?array $body = null): array {
    $ch = curl_init($url);
    $headers = ["X-API-Key: {$this->key}"];
    if ($body !== null) {
      $headers[] = "Content-Type: application/json";
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
    }
    curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_TIMEOUT => 20]);
    $res = json_decode(curl_exec($ch), true);
    curl_close($ch);
    return is_array($res) ? $res : ["ok" => false, "error" => "network_error"];
  }

  public function createOrder(float $amount, string $customer = "", string $webhook = ""): array {
    $body = ["amount" => $amount];
    if ($customer !== "") $body["customer_name"] = $customer;
    if ($webhook !== "") $body["webhook_url"] = $webhook;
    return $this->request($this->base . "/create-order", $body);
  }

  public function status(string $orderId): array {
    return $this->request($this->base . "/order-status?order_id=" . urlencode($orderId));
  }

  public static function verify(string $raw, string $header, string $secret): bool {
    parse_str(str_replace(",", "&", $header), $p);
    if (empty($p["t"]) || empty($p["v1"])) return false;
    return hash_equals(hash_hmac("sha256", $p["t"] . "." . $raw, $secret), $p["v1"]);
  }
}

2. checkout.php — return the popup order

checkout.php
<?php
require "autoupi.php";
// Require POST, authenticate the buyer, and validate CSRF using your app.
$api = new AutoUpi(getenv("AUTOUPI_KEY"));

$order = $api->createOrder(1499, "Rahul Sharma", "https://yoursite.com/autoupi-webhook.php");

if (empty($order["ok"])) {
  http_response_code(400);
  header("Content-Type: application/json");
  echo json_encode(["ok" => false, "error" => "Could not start payment"]);
  exit;
}

// store it so the webhook can find the buyer later
save_order($order["order_id"], $_SESSION["user_id"], $order["amount"]);

// save_order is your application's function, not an SDK method.
header("Content-Type: application/json");
echo json_encode(["ok" => true, "order_id" => $order["order_id"], "payment_url" => $order["payment_url"]]);
exit;

3. autoupi-webhook.php — get paid automatically

autoupi-webhook.php
<?php
require "autoupi.php";

$raw = file_get_contents("php://input");
$sig = $_SERVER["HTTP_X_AUTOUPI_SIGNATURE"] ?? "";

if (!AutoUpi::verify($raw, $sig, getenv("AUTOUPI_WEBHOOK_SECRET"))) {
  http_response_code(401);
  exit("bad signature");
}

$event = json_decode($raw, true);
if (($event["event"] ?? "") === "payment.paid") {
  // Look up the saved order and verify its amount before fulfilment.
  // Your mark_order_paid function must handle duplicate delivery atomically.
  mark_order_paid($event["order_id"], $event["amount"]);
}

http_response_code(200);
echo "ok";

No webhook endpoint yet? Your page can call your own server to check order-status while the popup is open and after a result. Authenticate the buyer, check order ownership and fulfil once only when the server confirms paid.

Plans & limits

PlanPriceQR limitValidity
Free₹03 successful (paid) QRs per cycle30 days, renews automatically
Pro₹299Unlimited QRs (paid or failed)28 days from payment, ends at 12:00 AM IST

The limit is checked on the server for every order — dashboard, payment links and API alike. When the Free limit is used up, create-order returns 402 PLAN_LIMIT. Pro can be renewed in the last 7 days; the new 28 days start right after the current ones end.

Errors

Errors return { "ok": false, "error": "code", "message": "…" }.

HTTPCodeFix
401invalid_api_keyKey missing, revoked or replaced by a regenerate.
400invalid_amountAmount must be between 1 and 1,00,000 with up to 2 decimals.
400invalid_webhook_urlwebhook_url must be a public https:// address.
400UPI_NOT_CONFIGUREDSave your Paytm MID and UPI ID on Settings first.
402PLAN_LIMITFree plan limit reached: 3 successful (PAID) QRs per 30-day cycle, counted across dashboard, links and API. Upgrade to Pro (₹299 for 28 days, unlimited QRs) on the Plan page, or wait for the free cycle to renew.
400invalid_requestThe JSON body is missing a field or has the wrong type.
404not_foundThe order ID does not belong to this key.
500server_errorTemporary problem. Retry the request.

Go-live checklist

  • ✓Paytm MID and UPI ID saved on UPI Accounts.
  • ✓API key and webhook secret stored only on your server (environment variables).
  • ✓Amount comes from your saved cart on the server, never from the browser.
  • ✓Webhook signature verified with hash_equals / timingSafeEqual before fulfilment.
  • ✓Order fulfilled only once, even if the webhook arrives twice.
  • ✓Tested one paid order, one expired order and Back → Yes on desktop and mobile.
  • ✓If you use CSP, https://pg.autoupi.in allowed in script-src and frame-src.

FAQ

Do I need a payment gateway account?

You need a Paytm for Business account (MID + UPI ID). Money reaches your own UPI account directly; this service only confirms and records the order.

How is a payment confirmed?

The checkout checks Paytm every 3 seconds. An order is marked paid only when Paytm reports success and the order ID, amount and currency all match.

How long is a link valid?

5 minutes. After that the order becomes expired. Create a new order to try again.

Which PHP version do I need?

PHP 7.4 or newer with the cURL extension — no composer package required.

Can I regenerate my API key?

Yes. Regenerating issues a new key and instantly disables the previous one. The webhook secret stays the same until you rotate it.