{
  "info": {
    "name": "SignSwifly API v1",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Send documents for signature from your own systems with the SignSwifly API, then follow and download them.\n\n1. Make an API key under Settings → API & webhooks in SignSwifly. Choose **Test** while you try things: a test key's envelopes only go to people in your team, are marked Test, don't count towards your plan, and are deleted after a week.\n2. In this collection's Variables, paste the key into `apiKey`.\n3. Run the requests in order. Each one saves the ids the next needs (`templateId`, `roleId`, `envelopeId`, `documentId`, `endpointId`).\n\nThe API reference, with every operation: https://anz.signswifly.com.au/developers\nThe guide: https://signswifly.com.au/help/api-webhooks-together.html"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{apiKey}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://anz.signswifly.com.au/api/v1"
    },
    {
      "key": "apiKey",
      "value": "",
      "description": "Your key, ssk_test_… while you try things."
    },
    {
      "key": "yourName",
      "value": "Your Name",
      "description": "Who signs the test envelope: someone in your workspace's team."
    },
    {
      "key": "yourEmail",
      "value": "you@example.com",
      "description": "Their email address, as it is in your team."
    },
    {
      "key": "templateId",
      "value": ""
    },
    {
      "key": "roleId",
      "value": ""
    },
    {
      "key": "envelopeId",
      "value": ""
    },
    {
      "key": "documentId",
      "value": ""
    },
    {
      "key": "endpointId",
      "value": ""
    },
    {
      "key": "webhookUrl",
      "value": "https://example.com/webhooks/signswifly",
      "description": "An HTTPS address of yours, or a request-inspection service's, that should hear about envelopes."
    }
  ],
  "item": [
    {
      "name": "1. Check your key",
      "item": [
        {
          "name": "Who this key acts as",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/me",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "me"
              ]
            },
            "description": "The workspace, the key, its scopes, and the owner or admin it acts as. Needs no scope."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "2. Templates",
      "item": [
        {
          "name": "List templates",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/templates?limit=25",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "templates?limit=25"
              ]
            },
            "description": "Your active templates. Saves the first one's id as templateId."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));",
                  "const first = pm.response.json().data[0];",
                  "if (first) pm.collectionVariables.set(\"templateId\", first.id);",
                  "pm.test(\"Has a template to send\", () => pm.expect(first, \"Make a template in the app and save it with Save & activate\").to.be.ok);"
                ]
              }
            }
          ]
        },
        {
          "name": "Get a template's roles and variables",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/templates/{{templateId}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "templates",
                "{{templateId}}"
              ]
            },
            "description": "Each role's id and label, and the variables to fill. Saves the first role's id as roleId."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));",
                  "const role = (pm.response.json().roles || [])[0];",
                  "if (role) pm.collectionVariables.set(\"roleId\", role.id);"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "3. An envelope",
      "item": [
        {
          "name": "Create a draft from the template",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "A new key for each new envelope. Send again with the same key within 24 hours and nothing happens twice."
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/envelopes/from-template",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "envelopes",
                "from-template"
              ]
            },
            "description": "Fills the template's first role with you. Without \"send\": true it stays a draft: nothing goes out, and no session is used. Add the template's variables under \"variables\", by name.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"templateId\": \"{{templateId}}\",\n  \"variables\": {},\n  \"recipients\": [\n    {\n      \"roleId\": \"{{roleId}}\",\n      \"name\": \"{{yourName}}\",\n      \"email\": \"{{yourEmail}}\"\n    }\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));",
                  "pm.collectionVariables.set(\"envelopeId\", pm.response.json().id);"
                ]
              }
            }
          ]
        },
        {
          "name": "Send the draft",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Idempotency-Key",
                "value": "{{$guid}}",
                "description": "A new key for each new envelope. Send again with the same key within 24 hours and nothing happens twice."
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/envelopes/{{envelopeId}}/send",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "envelopes",
                "{{envelopeId}}",
                "send"
              ]
            },
            "description": "Emails whoever's turn it is. With a live key this really goes out, and uses a session."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));"
                ]
              }
            }
          ]
        },
        {
          "name": "Get the envelope",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/envelopes/{{envelopeId}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "envelopes",
                "{{envelopeId}}"
              ]
            },
            "description": "Its status, recipients and documents. Saves the first document's id as documentId."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));",
                  "const doc = (pm.response.json().documents || [])[0];",
                  "if (doc) pm.collectionVariables.set(\"documentId\", doc.id);"
                ]
              }
            }
          ]
        },
        {
          "name": "Its status and each recipient's progress",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/envelopes/{{envelopeId}}/status",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "envelopes",
                "{{envelopeId}}",
                "status"
              ]
            },
            "description": "Who has viewed and signed, and who is still to."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));"
                ]
              }
            }
          ]
        },
        {
          "name": "Remind everyone whose turn it is",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/envelopes/{{envelopeId}}/remind",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "envelopes",
                "{{envelopeId}}",
                "remind"
              ]
            },
            "description": "Once an hour at most for each envelope."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));"
                ]
              }
            }
          ]
        },
        {
          "name": "Void it",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/envelopes/{{envelopeId}}/void",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "envelopes",
                "{{envelopeId}}",
                "void"
              ]
            },
            "description": "Stops a sent envelope: nobody can sign it any more."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));"
                ]
              }
            }
          ]
        },
        {
          "name": "List envelopes",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/envelopes?limit=25",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "envelopes?limit=25"
              ]
            },
            "description": "A page at a time: pass nextCursor back as cursor for the next."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "4. Signed documents",
      "item": [
        {
          "name": "Download a signed document",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/pdf"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/envelopes/{{envelopeId}}/documents/{{documentId}}/sealed",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "envelopes",
                "{{envelopeId}}",
                "documents",
                "{{documentId}}",
                "sealed"
              ]
            },
            "description": "Once everyone has signed. In Postman, choose Save response → Save to a file."
          }
        },
        {
          "name": "Download the certificate of completion",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/pdf"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/envelopes/{{envelopeId}}/certificate",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "envelopes",
                "{{envelopeId}}",
                "certificate"
              ]
            },
            "description": "Once everyone has signed."
          }
        },
        {
          "name": "Download everything as one PDF",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/pdf"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/envelopes/{{envelopeId}}/combined",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "envelopes",
                "{{envelopeId}}",
                "combined"
              ]
            },
            "description": "Where the envelope completed with a combined PDF (combinedDocumentAvailable)."
          }
        }
      ]
    },
    {
      "name": "5. Webhooks",
      "item": [
        {
          "name": "Add an endpoint",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/webhooks",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "webhooks"
              ]
            },
            "description": "Needs the webhooks:manage scope. The answer has the signing secret, once: keep it to check deliveries. Saves the endpoint's id as endpointId.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"url\": \"{{webhookUrl}}\",\n  \"events\": [\n    \"envelope.sent\",\n    \"recipient.viewed\",\n    \"recipient.signed\",\n    \"envelope.completed\",\n    \"envelope.declined\",\n    \"envelope.expired\",\n    \"envelope.voided\",\n    \"recipient.delivery_failed\"\n  ],\n  \"description\": \"Trying webhooks\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));",
                  "pm.collectionVariables.set(\"endpointId\", pm.response.json().id);"
                ]
              }
            }
          ]
        },
        {
          "name": "Send a test event",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/webhooks/{{endpointId}}/test",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "webhooks",
                "{{endpointId}}",
                "test"
              ]
            },
            "description": "Sends webhook.test to the endpoint now, once, without retries."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));"
                ]
              }
            }
          ]
        },
        {
          "name": "Its delivery log",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/webhooks/{{endpointId}}/deliveries",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "webhooks",
                "{{endpointId}}",
                "deliveries"
              ]
            },
            "description": "Each delivery's status, response code and the start of what your endpoint answered, for 30 days."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));"
                ]
              }
            }
          ]
        },
        {
          "name": "List endpoints",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/webhooks",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "webhooks"
              ]
            },
            "description": ""
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));"
                ]
              }
            }
          ]
        },
        {
          "name": "Remove the endpoint",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/webhooks/{{endpointId}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "webhooks",
                "{{endpointId}}"
              ]
            },
            "description": ""
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Answered 2xx\", () => pm.expect(pm.response.code).to.be.within(200, 299));"
                ]
              }
            }
          ]
        }
      ]
    }
  ]
}