# Documentación - API

# Antes de comenzar

Para iniciar la integración de cualquier servicio de CloudWorkflow API, es necesario poseer credenciales de acceso (una cuenta y llaves) generadas por un técnico de soporte de CloudWorkflow.

Todos los servicios manejados por CloudWorkflow API funcionan a través de peticiones HTTP en formato **JSON**.

### **Otros productos disponibles:**

PayGateway - [https://read.pygateway.com/](https://read.pygateway.com/)

![paygateway_api.png](https://read.pygateway.com/uploads/images/gallery/2023-12/scaled-1680-/paygateway-api.png)

# Endpoints y autenticación

## Endpoints o puntos de acceso

Los endpoints o puntos de conexión son los siguientes:

##### **Entorno de producción:**

[https://cworkflow.com/api](https://cworkflow.com/api)

##  

## Autenticación

Para todos los servicios protegidos (no públicos) es necesaria realizar autenticación. Para ello, se proveen llaves de API, las cuales constan de dos partes:

**API Key:** Token identificador de la llave.

**Secret Key**: Token secreto de la llave.

Para el envío de solicitudes, debe concatenar el API key y Secret Key separados por dos puntos ":", dicho token debe enviarlo en el header de todas las solicitudes que necesiten autenticación utilizando el header http "Authorization" bajo el tipo de autenticación "Bearer".

**Por ejemplo:**

Incluya en el header de su petición:

[![image.png](https://read.pygateway.com/uploads/images/gallery/2023-12/scaled-1680-/image.png)](https://read.pygateway.com/uploads/images/gallery/2023-12/image.png)

# Prueba de conexión y ejemplo de consumo

Puedes probar la conexión al servicio mediante el siguiente punto de enlace:

**GET**: test/connection

[![imagen.png](https://documentacion.cworkflow.com/uploads/images/gallery/2024-04/scaled-1680-/RW1imagen.png)](https://documentacion.cworkflow.com/uploads/images/gallery/2024-04/RW1imagen.png)

### Ejemplo de consumo (url):  


`https://cworkflow.com/api/test/connection`

# Creación y edición de tareas

### Creación de tareas

Este servicio permite crear tareas por medio de webservice.

**Consumo:**

`<strong>POST:</strong> /<span style="color: rgb(33, 33, 33); font-family: Inter, system-ui, -apple-system, 'system-ui', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">tareas/crear-editar</span>`

```json
{
    "flujo": "acvzcb2ec08fz5340c89c05ae89d711e652963485b58z7",
    "campos": {
        "campo1": "Un valor 1",
        "campo2": "Un valor 2"
    }
}
```

**Respuesta:**

El servicio devolverá un JSON indicando la creación de la tarea, así mismo el token de la tarea y su identificador. El token servirá en la edición de tareas.

```json
{
    "status": 1,
    "msg": "Tarea iniciada con éxito",
    "data": {
        "token": "1ba10cd5515618453cc017",
        "id": 111111
    }
}
```

### Edición de tareas

Este servicio permite crear cambiar de etapa una tarea. Atención: el parámetro "token" corresponde al token devuelto por la creación de tareas.

**Consumo:**

`<strong>POST:</strong> /<span style="color: rgb(33, 33, 33); font-family: Inter, system-ui, -apple-system, 'system-ui', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">tareas/crear-editar</span>`

```json
{
    "token": "1ba10cd5515618453cc017",
    "campos": {
        "campo3": "Un valor 3",
        "campo4": "Un valor 4"
    }
}
```

**Respuesta:**

El servicio devolverá un JSON el estatus de la actualización. Internamente, el sistema cambiará de estado la tarea y llenará los campos enviados.

```json
{
    "status": 1,
    "msg": "Tarea actualizada con éxito",
    "data": []
}
```

# Subir archivos a tarea

### Envío de un archivo a una tarea  


Este servicio permite subir archivos a tareas específicas.

**Consumo:**

`<strong>POST:</strong> /<span style="color: rgb(33, 33, 33); font-family: Inter, system-ui, -apple-system, 'system-ui', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span style="color: rgb(33, 33, 33); font-family: Inter, system-ui, -apple-system, 'system-ui', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">tareas/upload-file</span></span>`

> **NOTA: Este servicio NO se consume como JSON, debe consumirse como form-data.**

[![image.png](https://documentacion.cworkflow.com/uploads/images/gallery/2024-05/scaled-1680-/4mzimage.png)](https://documentacion.cworkflow.com/uploads/images/gallery/2024-05/4mzimage.png)

#### Descripción de parámetros:

**campoId (String):** Debe contener el identificador del campo de tipo archivo configurado en el flujo.

**token (String):** Debe contener el token de la tarea a la cual se cargará el archivo.

**file (File):** debe contener el archivo enviado en la estructura de un "POST con formulario" (form-data).

#### Ejemplo envío de archivo utilizando CURL (sin los demás parámetros): 

```bash
curl -i -X POST -H "Content-Type: multipart/form-data" 
-F "file=@archivoprueba.png" http://endpoint.de.workflow

```

**Respuesta:**

El servicio devolverá un JSON indicando la creación de la tarea, así mismo el token de la tarea y su identificador. El token servirá en la edición de tareas.

```json
{
    "status": 1,
    "msg": "Archivo subido con éxito",
    "data": {
        "key": "https://urldearchivosubido.png",
        "id": 111111
    }
}
```

# Ver campos disponibles por tarea

### Ver todos los campos  


Este servicio permite crear tareas por medio de webservice.

**Consumo:**

`<strong>POST:</strong> /<span style="color: rgb(33, 33, 33); font-family: Inter, system-ui, -apple-system, 'system-ui', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span style="color: rgb(33, 33, 33); font-family: Inter, system-ui, -apple-system, 'system-ui', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">tareas/ver-campos</span></span>`

```json
{
	"token": "845240e09011715621764"
}
```

**Respuesta:**

El servicio devolverá un JSON indicando la creación de la tarea, así mismo el token de la tarea y su identificador. El token servirá en la edición de tareas.

```json
{
    "status": 1,
    "msg": "Campos api éxito",
    "data": [
        {
            "nombre": null,
            "campos": {
                "campo1": {
                    "type": "text",
                    "label": "Campo de prueba",
                    "seccion": 0,
                    "id": "campo1"
                },
                "campo2": {
                    "type": "text",
                    "label": "Campo dos",
                    "seccion": 0,
                    "id": "campo2"
                },
                "campo3": {
                    "type": "select",
                    "label": "Campo tres",
                    "seccion": 0,
                    "id": "campo3"
                },
                "Firma_de_cliente": {
                    "type": "signature",
                    "label": "Firma de prueba",
                    "seccion": 0,
                    "id": "Firma_de_cliente"
                },
                "campofile": {
                    "type": "file",
                    "label": "Test",
                    "seccion": 0,
                    "id": "campofile"
                },
                "campos2": {
                    "type": "text",
                    "label": "Campo s2",
                    "seccion": 0,
                    "id": "campos2"
                }
            }
        }
    ]
}
```

### Campos por sección  


Este servicio permite crear cambiar de etapa una tarea. Atención: el parámetro "token" corresponde al token devuelto por la creación de tareas.

**Consumo:**

`<strong>POST:</strong> /<span style="color: rgb(33, 33, 33); font-family: Inter, system-ui, -apple-system, 'system-ui', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span style="color: rgb(33, 33, 33); font-family: Inter, system-ui, -apple-system, 'system-ui', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">tareas/ver-campos-por-seccion</span></span>`

```json
{
	"token": "845240e09011715621764"
}
```

**Respuesta:**

El servicio devolverá un JSON el estatus de la actualización. Internamente, el sistema cambiará de estado la tarea y llenará los campos enviados.

```json
{
    "status": 1,
    "msg": "Campos api éxito",
    "data": {
        "seccion_1": {
            "campo1": {
                "type": "text",
                "label": "Campo de prueba",
                "seccion": 0,
                "id": "campo1",
                "value": "test 1"
            },
            "campo2": {
                "type": "text",
                "label": "Campo dos",
                "seccion": 0,
                "id": "campo2",
                "value": "Un valor 2"
            },
            "campo3": {
                "type": "select",
                "label": "Campo tres",
                "seccion": 0,
                "id": "campo3",
                "value": ""
            },
            "Firma_de_cliente": {
                "type": "signature",
                "label": "Firma de prueba",
                "seccion": 0,
                "id": "Firma_de_cliente",
                "value": ""
            },
            "campofile": {
                "type": "file",
                "label": "Test",
                "seccion": 0,
                "id": "campofile",
                "value": ""
            }
        },
        "seccion_2": {
            "campos2": {
                "type": "text",
                "label": "Campo s2",
                "seccion": 0,
                "id": "campos2",
                "value": "Un valor 1"
            }
        }
    }
}
```

# Calcular flujo por tarea

### Creación de tareas

Este servicio permite calcular el flujo por tarea. Esto permite conocer el siguiente paso que el sistema realizará.

**Consumo:**

`<strong>POST:</strong> /<span style="color: rgb(33, 33, 33); font-family: Inter, system-ui, -apple-system, 'system-ui', 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', Helvetica, Arial, sans-serif; font-size: 12px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">tareas/crear-editar</span>`

```json
{
    "token": "2a5f8z56f98f117156220f"
}
```

**Respuesta:**

El servicio devolverá un JSON indicando la creación de la tarea, así mismo el token de la tarea y su identificador. El token servirá en la edición de tareas.

```json
{
    "status": 1,
    "msg": "Flujo calculado con éxito",
    "data": {
        "estado": "Sin estado",
        "actual": {
            "nodoId": "nodo_1715621733765",
            "typeObject": "input",
            "estOut": "Sin estado",
            "cmT": "",
            "expiracionNodo": false,
            "nodoName": "asdfasdfasdf",
            "type": "default",
            "label": "<div><b>Entrada</b></div><div><small>asdfasdfasdf</small></div>",
            "formulario": {
                "tipo": null,
                "secciones": [
                    {
                        "id": "asdfasdfsdf",
                        "show": true,
                        "campos": [
                            {
                                "id": "campos2",
                                "ttp": "",
                                "desc": "",
                                "mime": null,
                                "show": true,
                                "padre": false,
                                "activo": true,
                                "catFId": null,
                                "jsPost": null,
                                "nombre": "Campo s2",
                                "opened": true,
                                "mascara": null,
                                "options": [
                                    {
                                        "label": null,
                                        "value": null
                                    }
                                ],
                                "proceso": {
                                    "url": null,
                                    "type": null,
                                    "isXML": false,
                                    "header": null,
                                    "method": null,
                                    "salida": [],
                                    "entrada": null,
                                    "tipoRecibido": false,
                                    "configuracionS": []
                                },
                                "visible": true,
                                "cssClass": null,
                                "dependOn": [
                                    {
                                        "campoId": null,
                                        "campoIs": null,
                                        "campoValue": null
                                    }
                                ],
                                "readonly": 0,
                                "catFLabel": null,
                                "catFValue": null,
                                "requerido": 0,
                                "tipoCampo": "text",
                                "tokenMask": null,
                                "catalogoId": null,
                                "outputMask": null,
                                "longitudMax": "100",
                                "longitudMin": "0",
                                "contieneMask": false,
                                "layoutSizePc": 4,
                                "roles_assign": [],
                                "catalogoLabel": null,
                                "catalogoValue": null,
                                "deshabilitado": 0,
                                "grupos_assign": [],
                                "showInReports": false,
                                "canales_assign": [],
                                "valorCalculado": null,
                                "layoutSizeMobile": 12,
                                "archivadorDetalleId": 0,
                                "ph": "",
                                "valor": ""
                            }
                        ],
                        "nombre": null,
                        "opened": true,
                        "condiciones": [
                            {
                                "is": null,
                                "glue": "AND",
                                "value": null,
                                "campoId": null
                            }
                        ],
                        "instrucciones": null,
                        "seccionId": "0"
                    }
                ]
            },
            "btnText": {
                "prev": "",
                "next": "test",
                "finish": "",
                "cancel": ""
            },
            "btnS": {
                "n": "",
                "p": "",
                "f": "",
                "c": ""
            },
            "nodosEntrada": [
                "nodo_1697211212268"
            ],
            "nodosSalida": [
                "nodo_1707766099951"
            ],
            "nodosSalidaDecision": {
                "si": [],
                "no": []
            },
            "userAssign": {
                "user": "",
                "role": [],
                "group": [],
                "canal": [],
                "setuser_method": []
            },
            "procesos": [
                {
                    "pf": [],
                    "url": null,
                    "type": null,
                    "isXML": false,
                    "header": null,
                    "method": null,
                    "salida": [],
                    "entrada": null,
                    "tipoRecibido": false,
                    "configuracionS": []
                }
            ],
            "decisiones": [
                {
                    "glue": "AND",
                    "value": null,
                    "campoId": null,
                    "campoIs": null
                }
            ],
            "salidas": null,
            "salidaIsPDF": false,
            "salidaIsSMS": false,
            "salidaSMSstl": false,
            "salidaIsHTML": false,
            "salidaIsEmail": false,
            "salidaIsWhatsapp": false,
            "procesoWhatsapp": {
                "tpl": null,
                "url": null,
                "data": null,
                "token": null,
                "attachments": null
            },
            "procesoEmail": {
                "copia": [
                    {
                        "destino": null
                    }
                ],
                "asunto": null,
                "destino": null,
                "reenvio": false,
                "attachments": null,
                "salidasEmail": null
            },
            "roles_assign": [],
            "tareas_programadas": [],
            "pdfTpl": [],
            "salidaPDFId": "",
            "salidaPDFLabel": "",
            "salidaPDFDocsTk": "",
            "salidaSmsNum": "",
            "salidaSmsMsg": "",
            "saltoAutomatico": false,
            "tablasOcrCampos": []
        },
        "next": true,
        "prev": true,
        "bit": [
            {
                "id": 273985,
                "createdAt": "2024-05-13 11:41:05",
                "cotizacionId": 48231,
                "usuarioId": 2,
                "onlyPruebas": 0,
                "log": "Guardados datos en paso \"Inicio\"",
                "usuarioNombre": "Eddy Pérez",
                "usuarioCorporativo": "Sin usuario"
            }
        ],
        "d": {
            "FECHA_FORMULARIO": {
                "id": "FECHA_FORMULARIO",
                "nombre": "",
                "valor": "2024-05-13 11:41:05"
            },
            "FECHA_HOY": {
                "id": "FECHA_HOY",
                "nombre": "",
                "valor": "2024-05-13 17:46:24"
            },
            "FECHA_MODIFICACION": {
                "id": "FECHA_MODIFICACION",
                "nombre": "",
                "valor": "2024-05-13 11:41:05"
            },
            "CREADOR_NOMBRE": {
                "id": "CREADOR_NOMBRE",
                "nombre": "",
                "valor": "Eddy Pérez"
            },
            "CREADOR_CORP": {
                "id": "CREADOR_CORP",
                "nombre": "",
                "valor": null
            },
            "CREADOR_GRUPO": {
                "id": "CREADOR_GRUPO",
                "nombre": "",
                "valor": ""
            },
            "campo1": {
                "id": "campo1",
                "nombre": "campo1",
                "valor": ""
            },
            "campo2": {
                "id": "campo2",
                "nombre": "campo2",
                "valor": ""
            },
            "campo3": {
                "id": "campo3",
                "nombre": "campo3",
                "valor": ""
            },
            "Firma_de_cliente": {
                "id": "Firma_de_cliente",
                "nombre": "Firma_de_cliente",
                "valor": ""
            },
            "campofile": {
                "id": "campofile",
                "nombre": "campofile",
                "valor": "https://cworkflow.com/img/logo.ea7ba052.png"
            },
            "campos2": {
                "id": "campos2",
                "nombre": "campos2",
                "valor": ""
            }
        },
        "c": {
            "acc": true,
            "ed": "Formulario asociado al rol: Super Admin, usuario: eperez@abkbusiness.com (Eddy Pérez)",
            "ex": false,
            "exd": "",
            "no": 48231
        },
        "e": [
            "expirada"
        ]
    }
}
```