{
  "info": {
    "name": "SignYu eSign API",
    "description": "Aadhaar eSign API for developers. Set the `apiKey` collection variable to your API key (create one at https://signyu.com/app/developers), then run the requests in order. Create document sets the `documentId` variable automatically so the following requests work without edits.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{apiKey}}", "type": "string" }]
  },
  "variable": [
    { "key": "baseUrl", "value": "https://signyu.com/api/v1", "type": "string" },
    { "key": "apiKey", "value": "", "type": "string" },
    { "key": "documentId", "value": "", "type": "string" }
  ],
  "item": [
    {
      "name": "Create document",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "if (pm.response.code === 201) {",
              "  const json = pm.response.json();",
              "  if (json.documentId) {",
              "    pm.collectionVariables.set('documentId', json.documentId);",
              "  }",
              "}"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [],
        "url": {
          "raw": "{{baseUrl}}/documents",
          "host": ["{{baseUrl}}"],
          "path": ["documents"]
        },
        "body": {
          "mode": "formdata",
          "formdata": [
            { "key": "file", "type": "file", "src": null },
            { "key": "name", "value": "Service Agreement", "type": "text" }
          ]
        },
        "description": "Upload a PDF (application/pdf, up to 10MB) as the `file` field to create a document. The response `documentId` is stored automatically for the next requests."
      }
    },
    {
      "name": "Add signers",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "url": {
          "raw": "{{baseUrl}}/documents/{{documentId}}/signers",
          "host": ["{{baseUrl}}"],
          "path": ["documents", "{{documentId}}", "signers"]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"signers\": [\n    { \"name\": \"Asha Rao\", \"phone\": \"9876543210\", \"email\": \"asha@example.com\" }\n  ]\n}",
          "options": { "raw": { "language": "json" } }
        },
        "description": "Add up to 6 signers. Only allowed while the document is PENDING. Signers sign in the order they are added. Omit advanced to use the default fixed stamp slot."
      }
    },
    {
      "name": "Add signers (with signature placement)",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "url": {
          "raw": "{{baseUrl}}/documents/{{documentId}}/signers",
          "host": ["{{baseUrl}}"],
          "path": ["documents", "{{documentId}}", "signers"]
        },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"signers\": [\n    {\n      \"name\": \"Asha Rao\",\n      \"phone\": \"9876543210\",\n      \"email\": \"asha@example.com\",\n      \"advanced\": {\n        \"signaturePlacement\": {\n          \"positions\": [\n            { \"page\": 2, \"x\": 31, \"y\": 257, \"width\": 253, \"height\": 110 }\n          ]\n        }\n      }\n    }\n  ]\n}",
          "options": { "raw": { "language": "json" } }
        },
        "description": "Advanced: custom signature placement. Coordinates are PDF points with origin at the bottom-left of the page (y = bottom edge). Min box size 140×110. If measuring in top-left / pdf.js space: y_bottom = pageHeight - y_top - height. See docs/emudhra-signature-placement.md."
      }
    },
    {
      "name": "Send for signature",
      "request": {
        "method": "POST",
        "header": [],
        "url": {
          "raw": "{{baseUrl}}/documents/{{documentId}}/send",
          "host": ["{{baseUrl}}"],
          "path": ["documents", "{{documentId}}", "send"]
        },
        "description": "Deducts one credit per signer, marks the document SENT, emails a signing link to each signer, and returns those links."
      }
    },
    {
      "name": "Get document",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{baseUrl}}/documents/{{documentId}}",
          "host": ["{{baseUrl}}"],
          "path": ["documents", "{{documentId}}"]
        },
        "description": "Returns the document status, each signer's progress, and a download URL once the document is COMPLETED."
      }
    },
    {
      "name": "List documents",
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{baseUrl}}/documents?limit=20&offset=0",
          "host": ["{{baseUrl}}"],
          "path": ["documents"],
          "query": [
            { "key": "limit", "value": "20" },
            { "key": "offset", "value": "0" }
          ]
        },
        "description": "Lists your documents, most recent first, with a summary of signer progress."
      }
    }
  ]
}
