{
  "info": {
    "name": "STCP DirectLink API v2 (pt) — versão 9",
    "description": "Chamadas da API REST do STCP DirectLink 9. Preencha as variáveis baseUrl, username e password. \"Obter token (password grant)\" grava o token na variável token, usada pelas rotas protegidas (Authorization: Bearer). A partir da versão 9, upload, listagens, relatório e logout não aceitam Basic. As listagens gravam o linkURL do primeiro arquivo em fileLink e backupFileLink; o login com MFA grava o link do desafio em mfaLink. Habilite o header CF-Turnstile-Response somente se o ambiente exigir o 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": "Disponibilidade",
      "item": [
        {
          "name": "Health check",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/healthcheck",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "healthcheck"
              ]
            },
            "auth": {
              "type": "noauth"
            }
          }
        }
      ]
    },
    {
      "name": "Autenticação",
      "item": [
        {
          "name": "Obter 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": "Obter 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 emitido pelo provedor de origem"
                },
                {
                  "key": "provider",
                  "value": "{{provider}}",
                  "description": "Identificador do provedor JWT cadastrado"
                }
              ]
            }
          },
          "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": "Login local (Basic)",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "CF-Turnstile-Response",
                "value": "{{turnstileToken}}",
                "description": "Token do Cloudflare Turnstile (somente se o ambiente exigir)",
                "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": "Concluir MFA",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{mfaLink}}"
            },
            "auth": {
              "type": "noauth"
            },
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "p",
                  "value": "",
                  "description": "PIN ou código TOTP"
                }
              ]
            },
            "description": "Use o linkURL retornado no 206 do login (gravado em mfaLink)"
          }
        },
        {
          "name": "Logout",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/auth/logout",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "auth",
                "logout"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Senha",
      "item": [
        {
          "name": "Primeiro acesso",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "CF-Turnstile-Response",
                "value": "{{turnstileToken}}",
                "description": "Token do Cloudflare Turnstile (somente se o ambiente exigir)",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/auth/firstaccess?u={{username}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "auth",
                "firstaccess"
              ],
              "query": [
                {
                  "key": "u",
                  "value": "{{username}}",
                  "description": "Usuário cadastrado na plataforma"
                }
              ]
            },
            "auth": {
              "type": "noauth"
            }
          }
        },
        {
          "name": "Esqueceu a senha",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "CF-Turnstile-Response",
                "value": "{{turnstileToken}}",
                "description": "Token do Cloudflare Turnstile (somente se o ambiente exigir)",
                "disabled": true
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/auth/forget?u={{username}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "auth",
                "forget"
              ],
              "query": [
                {
                  "key": "u",
                  "value": "{{username}}",
                  "description": "Usuário cadastrado na plataforma"
                }
              ]
            },
            "auth": {
              "type": "noauth"
            }
          }
        },
        {
          "name": "Alteração de senha",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{passwordLink}}"
            },
            "auth": {
              "type": "noauth"
            },
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "p",
                  "value": "",
                  "description": "PIN enviado ao usuário"
                },
                {
                  "key": "z",
                  "value": "",
                  "description": "Nova senha"
                }
              ]
            },
            "description": "Grave em passwordLink o link seguro recebido pelo usuário"
          }
        }
      ]
    },
    {
      "name": "Transferências",
      "item": [
        {
          "name": "Upload multipart",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/upload",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "upload"
              ]
            },
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "file",
                  "type": "file",
                  "src": "",
                  "description": "Arquivo a enviar"
                },
                {
                  "key": "d",
                  "value": "",
                  "type": "text",
                  "description": "Usuário de destino (opcional)"
                },
                {
                  "key": "m",
                  "value": "",
                  "type": "text",
                  "description": "E-mail do destinatário do link (opcional)"
                },
                {
                  "key": "c",
                  "value": "",
                  "type": "text",
                  "description": "Celular do destinatário do link (opcional)"
                },
                {
                  "key": "h",
                  "value": "",
                  "type": "text",
                  "description": "Hash SHA-256 hexadecimal do arquivo (opcional)"
                },
                {
                  "key": "n",
                  "value": "",
                  "type": "text",
                  "description": "E-mail ou identificação do remetente (opcional)"
                },
                {
                  "key": "i",
                  "value": "",
                  "type": "text",
                  "description": "Informação adicional ou mensagem (opcional)"
                }
              ]
            }
          }
        },
        {
          "name": "Upload binário",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/octet-stream"
              },
              {
                "key": "X-STCPDIRECTLINK-FILENAME",
                "value": "",
                "description": "Nome do arquivo"
              },
              {
                "key": "X-STCPDIRECTLINK-DESTINATION",
                "value": "",
                "description": "Usuário de destino (opcional)"
              },
              {
                "key": "X-STCPDIRECTLINK-EMAIL",
                "value": "",
                "description": "E-mail do destinatário do link (opcional)"
              },
              {
                "key": "X-STCPDIRECTLINK-MOBILE",
                "value": "",
                "description": "Celular do destinatário do link (opcional)"
              },
              {
                "key": "X-STCPDIRECTLINK-HASH",
                "value": "",
                "description": "Hash SHA-256 hexadecimal do arquivo (opcional)"
              },
              {
                "key": "X-STCPDIRECTLINK-EMAIL-FROM",
                "value": "",
                "description": "E-mail ou identificação do remetente (opcional)"
              },
              {
                "key": "X-STCPDIRECTLINK-INFO",
                "value": "",
                "description": "Informação adicional ou mensagem (opcional)"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/upload",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "upload"
              ]
            },
            "body": {
              "mode": "file",
              "file": {
                "src": ""
              }
            }
          }
        },
        {
          "name": "Lista de arquivos para download",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/download/list?page=0",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "download",
                "list"
              ],
              "query": [
                {
                  "key": "page",
                  "value": "0",
                  "description": "Página, a partir de 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": "Lista de arquivos do backup",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/download/list/backup?page=0",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "download",
                "list",
                "backup"
              ],
              "query": [
                {
                  "key": "page",
                  "value": "0",
                  "description": "Página, a partir de 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 do arquivo",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{fileLink}}"
            },
            "auth": {
              "type": "noauth"
            },
            "description": "linkURL gravado pela listagem (fileLink)"
          }
        },
        {
          "name": "Download do arquivo do backup",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{backupFileLink}}"
            },
            "auth": {
              "type": "noauth"
            },
            "description": "linkURL gravado pela listagem do backup (backupFileLink)"
          }
        }
      ]
    },
    {
      "name": "Relatório",
      "item": [
        {
          "name": "Relatório de transferências",
          "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 = downloads concluídos; 7 = uploads concluídos"
                },
                {
                  "key": "days",
                  "value": "7",
                  "description": "Período em dias"
                },
                {
                  "key": "page",
                  "value": "0",
                  "description": "Página, a partir de 0"
                },
                {
                  "key": "filterfile",
                  "value": "",
                  "description": "Trecho do nome do arquivo (opcional)",
                  "disabled": true
                }
              ]
            }
          }
        }
      ]
    }
  ],
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://<dominio>/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": ""
    }
  ]
}
