{
  "info": {
    "name": "STCP DirectLink API v2 (en) — version 9",
    "description": "STCP DirectLink 9 REST API calls. Fill in the baseUrl, username and password variables. \"Get token (password grant)\" stores the token in the token variable, used by the protected routes (Authorization: Bearer). Starting with version 9, upload, listings, report and sign-out do not accept Basic. The listings store the first file linkURL in fileLink and backupFileLink; sign-in with MFA stores the challenge link in mfaLink. Enable the CF-Turnstile-Response header only if the environment requires Cloudflare Turnstile.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{token}}",
        "type": "string"
      }
    ]
  },
  "item": [
    {
      "name": "Availability",
      "item": [
        {
          "name": "Health check",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/healthcheck",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "healthcheck"
              ]
            },
            "auth": {
              "type": "noauth"
            }
          }
        }
      ]
    },
    {
      "name": "Authentication",
      "item": [
        {
          "name": "Get token (password grant)",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/oauth2/token",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "oauth2",
                "token"
              ]
            },
            "auth": {
              "type": "noauth"
            },
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "grant_type",
                  "value": "password"
                },
                {
                  "key": "username",
                  "value": "{{username}}"
                },
                {
                  "key": "password",
                  "value": "{{password}}"
                }
              ]
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const r = pm.response.json();",
                  "if (r.access_token) { pm.collectionVariables.set('token', r.access_token); }"
                ]
              }
            }
          ]
        },
        {
          "name": "Get token (token exchange)",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/auth/token",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "auth",
                "token"
              ]
            },
            "auth": {
              "type": "noauth"
            },
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "grant_type",
                  "value": "urn:ietf:params:oauth:grant-type:token-exchange"
                },
                {
                  "key": "subject_token_type",
                  "value": "urn:ietf:params:oauth:token-type:jwt"
                },
                {
                  "key": "subject_token",
                  "value": "{{subjectToken}}",
                  "description": "JWT issued by the source provider"
                },
                {
                  "key": "provider",
                  "value": "{{provider}}",
                  "description": "Identifier of the registered JWT provider"
                }
              ]
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const r = pm.response.json();",
                  "if (r.access_token) { pm.collectionVariables.set('token', r.access_token); }"
                ]
              }
            }
          ]
        },
        {
          "name": "Local sign-in (Basic)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "CF-Turnstile-Response",
                "value": "{{turnstileToken}}",
                "description": "Cloudflare Turnstile token (only if the environment requires it)",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/auth/login",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "auth",
                "login"
              ]
            },
            "auth": {
              "type": "basic",
              "basic": [
                {
                  "key": "username",
                  "value": "{{username}}",
                  "type": "string"
                },
                {
                  "key": "password",
                  "value": "{{password}}",
                  "type": "string"
                }
              ]
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "if (pm.response.code === 206) { const r = pm.response.json(); if (r.linkURL) { pm.collectionVariables.set('mfaLink', r.linkURL); } }"
                ]
              }
            }
          ]
        },
        {
          "name": "Complete MFA",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{mfaLink}}"
            },
            "auth": {
              "type": "noauth"
            },
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "p",
                  "value": "",
                  "description": "PIN or TOTP code"
                }
              ]
            },
            "description": "Use the linkURL returned in the sign-in 206 (stored in mfaLink)"
          }
        },
        {
          "name": "Sign out",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/auth/logout",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "auth",
                "logout"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Password",
      "item": [
        {
          "name": "First access",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "CF-Turnstile-Response",
                "value": "{{turnstileToken}}",
                "description": "Cloudflare Turnstile token (only if the environment requires it)",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/auth/firstaccess?u={{username}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "auth",
                "firstaccess"
              ],
              "query": [
                {
                  "key": "u",
                  "value": "{{username}}",
                  "description": "User registered on the platform"
                }
              ]
            },
            "auth": {
              "type": "noauth"
            }
          }
        },
        {
          "name": "Forgot password",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "CF-Turnstile-Response",
                "value": "{{turnstileToken}}",
                "description": "Cloudflare Turnstile token (only if the environment requires it)",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/auth/forget?u={{username}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "auth",
                "forget"
              ],
              "query": [
                {
                  "key": "u",
                  "value": "{{username}}",
                  "description": "User registered on the platform"
                }
              ]
            },
            "auth": {
              "type": "noauth"
            }
          }
        },
        {
          "name": "Change password",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{passwordLink}}"
            },
            "auth": {
              "type": "noauth"
            },
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "p",
                  "value": "",
                  "description": "PIN sent to the user"
                },
                {
                  "key": "z",
                  "value": "",
                  "description": "New password"
                }
              ]
            },
            "description": "Store the secure link received by the user in passwordLink"
          }
        }
      ]
    },
    {
      "name": "Transfers",
      "item": [
        {
          "name": "Multipart upload",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/upload",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "upload"
              ]
            },
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "file",
                  "type": "file",
                  "src": "",
                  "description": "File to send"
                },
                {
                  "key": "d",
                  "value": "",
                  "type": "text",
                  "description": "Destination user (optional)"
                },
                {
                  "key": "m",
                  "value": "",
                  "type": "text",
                  "description": "Link recipient email (optional)"
                },
                {
                  "key": "c",
                  "value": "",
                  "type": "text",
                  "description": "Link recipient mobile number (optional)"
                },
                {
                  "key": "h",
                  "value": "",
                  "type": "text",
                  "description": "Hexadecimal SHA-256 hash of the file (optional)"
                },
                {
                  "key": "n",
                  "value": "",
                  "type": "text",
                  "description": "Sender email or identification (optional)"
                },
                {
                  "key": "i",
                  "value": "",
                  "type": "text",
                  "description": "Additional information or message (optional)"
                }
              ]
            }
          }
        },
        {
          "name": "Binary upload",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/octet-stream"
              },
              {
                "key": "X-STCPDIRECTLINK-FILENAME",
                "value": "",
                "description": "File name"
              },
              {
                "key": "X-STCPDIRECTLINK-DESTINATION",
                "value": "",
                "description": "Destination user (optional)"
              },
              {
                "key": "X-STCPDIRECTLINK-EMAIL",
                "value": "",
                "description": "Link recipient email (optional)"
              },
              {
                "key": "X-STCPDIRECTLINK-MOBILE",
                "value": "",
                "description": "Link recipient mobile number (optional)"
              },
              {
                "key": "X-STCPDIRECTLINK-HASH",
                "value": "",
                "description": "Hexadecimal SHA-256 hash of the file (optional)"
              },
              {
                "key": "X-STCPDIRECTLINK-EMAIL-FROM",
                "value": "",
                "description": "Sender email or identification (optional)"
              },
              {
                "key": "X-STCPDIRECTLINK-INFO",
                "value": "",
                "description": "Additional information or message (optional)"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/upload",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "upload"
              ]
            },
            "body": {
              "mode": "file",
              "file": {
                "src": ""
              }
            }
          }
        },
        {
          "name": "List files for download",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/download/list?page=0",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "download",
                "list"
              ],
              "query": [
                {
                  "key": "page",
                  "value": "0",
                  "description": "Page, starting at 0"
                }
              ]
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const r = pm.response.json();",
                  "if (r.files && r.files.length) { pm.collectionVariables.set('fileLink', r.files[0].linkURL); }"
                ]
              }
            }
          ]
        },
        {
          "name": "List backup files",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/download/list/backup?page=0",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "download",
                "list",
                "backup"
              ],
              "query": [
                {
                  "key": "page",
                  "value": "0",
                  "description": "Page, starting at 0"
                }
              ]
            }
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const r = pm.response.json();",
                  "if (r.files && r.files.length) { pm.collectionVariables.set('backupFileLink', r.files[0].linkURL); }"
                ]
              }
            }
          ]
        },
        {
          "name": "Download file",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{fileLink}}"
            },
            "auth": {
              "type": "noauth"
            },
            "description": "linkURL stored by the listing (fileLink)"
          }
        },
        {
          "name": "Download backup file",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{backupFileLink}}"
            },
            "auth": {
              "type": "noauth"
            },
            "description": "linkURL stored by the backup listing (backupFileLink)"
          }
        }
      ]
    },
    {
      "name": "Report",
      "item": [
        {
          "name": "Transfer report",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/report?filterdirection=7&days=7&page=0",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "report"
              ],
              "query": [
                {
                  "key": "filterdirection",
                  "value": "7",
                  "description": "5 = completed downloads; 7 = completed uploads"
                },
                {
                  "key": "days",
                  "value": "7",
                  "description": "Period in days"
                },
                {
                  "key": "page",
                  "value": "0",
                  "description": "Page, starting at 0"
                },
                {
                  "key": "filterfile",
                  "value": "",
                  "description": "Part of the file name (optional)",
                  "disabled": true
                }
              ]
            }
          }
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://<domain>/directlink/v2"
    },
    {
      "key": "username",
      "value": ""
    },
    {
      "key": "password",
      "value": ""
    },
    {
      "key": "token",
      "value": ""
    },
    {
      "key": "turnstileToken",
      "value": ""
    },
    {
      "key": "subjectToken",
      "value": ""
    },
    {
      "key": "provider",
      "value": ""
    },
    {
      "key": "mfaLink",
      "value": ""
    },
    {
      "key": "passwordLink",
      "value": ""
    },
    {
      "key": "fileLink",
      "value": ""
    },
    {
      "key": "backupFileLink",
      "value": ""
    }
  ]
}
