---
title: Cash Out
slug: cash-out
description: Learn how to generate authentication and process transactions effortlessly using the Sugaway API with this comprehensive document. From completing initial steps to securely storing keys, discover step-by-step instructions and code examples in various prog
icon: 🏦
createdAt: 2023-07-20T20:06:34.464Z
---

Requerimientos

1. Completar los [Primeros Pasos](https://www.sugaway.dev/)
2. Generar una llave Pública bajo el Standard OpenPGP
3. Enviar la llave pública a integraciones\@sugaway.com especificando el API Key generado en el punto 1

Aclaraciones Generales

- Cash out se considera una transacción autenticada, el servicio generará un Token de Autenticación que sólo podrá ser desencriptado con la llave Privada generada en el paso 2 de los requerimientos
- La llave Privada deberá ser almacenada de manera segura ya que toda transacción autenticada no podrá ser reversada ni reclamada.
- Cada transacción generada deberá ser autenticada con la llave perteneciente al API Key o App generada para su aplicativo.
- Cada código de autenticación tendrá una vida de 15 minutos, su duración será especificada en la respuesta
- Esta operación sólo podrá ser realizada de Servidor a Servidor y jamás deberá ser utilizada desde un frontend.



:::ApiMethodV2
```json
{
  "name": "Generar Autenticación",
  "method": "POST",
  "url": "https://api.sugaway.com/p/developer/app/auth",
  "description": "Permite generar un Token de Autenticación de Operación.",
  "tab": "examples",
  "examples": {
    "languages": [
      {
        "id": "9ROu50zRiQIs7DevaZOrZ",
        "language": "curl",
        "code": "curl --location --request POST 'https://api.sugaway.com/p/developer/app/auth' \\\n--header 'Accept: application/json' \\\n--header 'x-api-key: string' \\\n--header 'x-access-token: string' \\\n--data-raw '{\"type\":\"string\"}'",
        "customLabel": ""
      },
      {
        "id": "waAde8bQtgFMucJ-0LAXH",
        "language": "nodejs",
        "code": "var request = require('request');\nvar options = {\n   'method': 'POST',\n   'url': 'https://api.sugaway.com/p/developer/app/auth',\n   'headers': {\n      'Accept': 'application/json',\n      'x-api-key': 'string',\n      'x-access-token': 'string'\n   },\n   body: '{\"type\":\"string\"}'\n\n};\nrequest(options, function (error, response) {\n   if (error) throw new Error(error);\n   console.log(response.body);\n});\n",
        "customLabel": ""
      },
      {
        "id": "0u9taIl-lL-OkQxMIhlt6",
        "language": "javascript",
        "code": "var myHeaders = new Headers();\nmyHeaders.append(\"Accept\", \"application/json\");\nmyHeaders.append(\"x-api-key\", \"string\");\nmyHeaders.append(\"x-access-token\", \"string\");\n\nvar raw = \"{\\\"type\\\":\\\"string\\\"}\";\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.sugaway.com/p/developer/app/auth\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));",
        "customLabel": ""
      },
      {
        "id": "mXIbZLNpDybGx9WL2cExW",
        "language": "python",
        "code": "import requests\n\nurl = \"https://api.sugaway.com/p/developer/app/auth\"\n\npayload = \"{\\\"type\\\":\\\"string\\\"}\"\nheaders = {\n   'Accept': 'application/json',\n   'x-api-key': 'string',\n   'x-access-token': 'string'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n",
        "customLabel": ""
      },
      {
        "id": "v3xEiXVVFHT4es1vC7SHG",
        "language": "ruby",
        "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.sugaway.com/p/developer/app/auth\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"Accept\"] = \"application/json\"\nrequest[\"x-api-key\"] = \"string\"\nrequest[\"x-access-token\"] = \"string\"\nrequest.body = \"{\\\"type\\\":\\\"string\\\"}\"\n\nresponse = https.request(request)\nputs response.read_body\n",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "9ROu50zRiQIs7DevaZOrZ"
  },
  "results": {
    "languages": [
      {
        "id": "mWPGgtgfkQfXN_uhz0d9u",
        "language": "200",
        "customLabel": "",
        "code": "{\n    \"result\": true,\n    \"data\": {\n        \"token\": \"encrypted token\",\n        \"expiresAt\": 1689884692491\n    }\n}"
      }
    ],
    "selectedLanguageId": "mWPGgtgfkQfXN_uhz0d9u"
  },
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [
      {
        "name": "x-api-key",
        "kind": "required",
        "type": "string",
        "description": "API Key que identifica la App",
        "children": []
      },
      {
        "name": "x-access-token",
        "kind": "required",
        "type": "string",
        "description": "Access Token que identifica la Entidad sobre la cual se operará",
        "children": []
      }
    ],
    "bodyDataParameters": [
      {
        "name": "type",
        "kind": "required",
        "type": "string",
        "description": "Valor: 2FA"
      }
    ],
    "formDataParameters": []
  },
  "currentNewParameter": {
    "label": "Header Parameter",
    "value": "headerParameters"
  },
  "hasTryItOut": false,
  "autoGeneratedAnchorSlug": "generar-autenticacin",
  "legacyHash": "3SqUMh8ACD-rWNlupBJ9q"
}
```
:::

:::hint{type="warning"}
El Token retornado sólo podrá ser desencriptado por la llave Privada de la llave Pública Provista.
:::



# Generación de Transacción

### Paso 1: inicializar Cash-Out

:::ApiMethodV2
```json
{
  "name": "Inicializar el Cash-Out",
  "method": "POST",
  "url": "https://api.sugaway.com/p/cashout",
  "description": "Permite iniciar el proceso de cash-out de una cuenta",
  "tab": "examples",
  "examples": {
    "languages": [
      {
        "id": "VTa-VKeNbUG9T6_oHeY16",
        "language": "curl",
        "code": "curl --location --request POST 'https://api.sugaway.com/p/cashout' \\\n--header 'Accept: application/json' \\\n--header 'x-api-key: string' \\\n--header 'x-access-token: string' \\\n--data-raw '{\"total\":\"Number\",\"currency\":\"string\",\"reference\":\"string\",\"account\":\"string\",\"webhook\":\"string\",\"description\":\"string\",\"test\":\"Boolean\"}'",
        "customLabel": ""
      },
      {
        "id": "VhU6p1y6vLnf4Mu73tV6b",
        "language": "nodejs",
        "code": "var request = require('request');\nvar options = {\n   'method': 'POST',\n   'url': 'https://api.sugaway.com/p/cashout',\n   'headers': {\n      'Accept': 'application/json',\n      'x-api-key': 'string',\n      'x-access-token': 'string'\n   },\n   body: '{\"total\":\"Number\",\"currency\":\"string\",\"reference\":\"string\",\"account\":\"string\",\"webhook\":\"string\",\"description\":\"string\",\"test\":\"Boolean\"}'\n\n};\nrequest(options, function (error, response) {\n   if (error) throw new Error(error);\n   console.log(response.body);\n});\n",
        "customLabel": ""
      },
      {
        "id": "fBHvG_8PIOeOox8-VHidr",
        "language": "javascript",
        "code": "var myHeaders = new Headers();\nmyHeaders.append(\"Accept\", \"application/json\");\nmyHeaders.append(\"x-api-key\", \"string\");\nmyHeaders.append(\"x-access-token\", \"string\");\n\nvar raw = \"{\\\"total\\\":\\\"Number\\\",\\\"currency\\\":\\\"string\\\",\\\"reference\\\":\\\"string\\\",\\\"account\\\":\\\"string\\\",\\\"webhook\\\":\\\"string\\\",\\\"description\\\":\\\"string\\\",\\\"test\\\":\\\"Boolean\\\"}\";\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.sugaway.com/p/cashout\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));",
        "customLabel": ""
      },
      {
        "id": "RpEbsy21Nv1VshYZCDK3T",
        "language": "python",
        "code": "import requests\n\nurl = \"https://api.sugaway.com/p/cashout\"\n\npayload = \"{\\\"total\\\":\\\"Number\\\",\\\"currency\\\":\\\"string\\\",\\\"reference\\\":\\\"string\\\",\\\"account\\\":\\\"string\\\",\\\"webhook\\\":\\\"string\\\",\\\"description\\\":\\\"string\\\",\\\"test\\\":\\\"Boolean\\\"}\"\nheaders = {\n   'Accept': 'application/json',\n   'x-api-key': 'string',\n   'x-access-token': 'string'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n",
        "customLabel": ""
      },
      {
        "id": "7RryXC_cuWsGc08nIyxjG",
        "language": "ruby",
        "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.sugaway.com/p/cashout\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"Accept\"] = \"application/json\"\nrequest[\"x-api-key\"] = \"string\"\nrequest[\"x-access-token\"] = \"string\"\nrequest.body = \"{\\\"total\\\":\\\"Number\\\",\\\"currency\\\":\\\"string\\\",\\\"reference\\\":\\\"string\\\",\\\"account\\\":\\\"string\\\",\\\"webhook\\\":\\\"string\\\",\\\"description\\\":\\\"string\\\",\\\"test\\\":\\\"Boolean\\\"}\"\n\nresponse = https.request(request)\nputs response.read_body\n",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "VTa-VKeNbUG9T6_oHeY16"
  },
  "results": {
    "languages": [
      {
        "id": "EiyQhSmS-H3DbBPEZ4I7z",
        "language": "200",
        "customLabel": "",
        "code": "{\n    \"result\": true,\n    \"data\": {\n        \"intent\": {\n            \"token\": \"9396F724-80CC-49BF-8391-BC18B525E3AC\"\n        }\n    }\n}"
      },
      {
        "id": "FG7p6BBZJAzXjnQLVQHFy",
        "language": "404",
        "customLabel": "",
        "code": "{\n      \"message\": \"Ain't no cake like that.\"\n    }"
      }
    ],
    "selectedLanguageId": "EiyQhSmS-H3DbBPEZ4I7z"
  },
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [
      {
        "name": "x-api-key",
        "kind": "required",
        "type": "string",
        "description": "Clave API de su aplicación.",
        "children": []
      },
      {
        "name": "x-access-token",
        "kind": "required",
        "type": "string",
        "description": "Token de acceso a su comercio.",
        "children": []
      }
    ],
    "bodyDataParameters": [
      {
        "name": "total",
        "kind": "required",
        "type": "Number",
        "description": "Total de la operación"
      },
      {
        "name": "currency",
        "kind": "required",
        "type": "string",
        "description": "Código de Moneda. Aceptados: ARS",
        "children": []
      },
      {
        "name": "reference",
        "kind": "required",
        "type": "string",
        "description": "Factura, Recibo o referencia del pago a Realizar. Puede ser un identificador de un sistema externo para seguimiento. Este Identificador pertenece a su sistema pero debe ser único para cada operación. SUGA no permite 2 operaciones con el mismo reference.",
        "children": []
      },
      {
        "name": "account",
        "kind": "optional",
        "type": "string",
        "description": "Cuenta de la Entidad. Este dato es opcional y no debe ser enviado si no es indicado por nuestro equipo",
        "children": []
      },
      {
        "name": "webhook",
        "kind": "optional",
        "type": "string",
        "description": "URL a la cual será informado el pago mediante WebHooks (POST)",
        "children": []
      },
      {
        "name": "description",
        "kind": "optional",
        "type": "string",
        "description": "Descripción de la operación que será mostrada en la consola de SUGA.",
        "children": []
      },
      {
        "name": "test",
        "kind": "optional",
        "type": "Boolean",
        "description": "Permite colocar la operación en Modo TEST.",
        "children": []
      },
      {
        "name": "customer",
        "kind": "optional",
        "type": "Object",
        "description": "Cliente al que se envía el cashout",
        "children": [
          {
            "name": "identification",
            "kind": "optional",
            "type": "string",
            "description": "En Argentina CUIL o CUIT"
          },
          {
            "name": "name",
            "kind": "optional",
            "type": "string",
            "description": "Nombre completo del cliente"
          }
        ]
      }
    ],
    "formDataParameters": []
  },
  "currentNewParameter": {
    "label": "Body Parameter",
    "value": "bodyDataParameters"
  },
  "hasTryItOut": false,
  "autoGeneratedAnchorSlug": "inicializar-el-cash-out",
  "legacyHash": "TQgqN7xbtq4NKj1_zWvkI"
}
```
:::

### Paso 2: Generar Token del Medio de Pago

[Generar Token de Tipo "Bank"](https://www.sugaway.dev/desde-backend#HB8aeYwLm3xHyBNZ0r5qO)

### Paso 3: Procesar la Operación

[Invocar el Procesamiento de la Operación](https://www.sugaway.dev/KAcQ-procesamiento)
