{
  "openapi": "3.1.0",
  "info": {
    "title": "Shimli API",
    "version": "3.0.0",
    "description": "API REST de Shimli para mensajería conversacional multi-canal (WhatsApp, Facebook Messenger, SMS), CRM, campañas, catálogo de productos e investigaciones con IA. Base URL: https://api.shimli.app",
    "contact": {
      "name": "Shimli",
      "url": "https://www.shimliapp.com",
      "email": "hi@shimli.app"
    }
  },
  "servers": [
    {
      "url": "https://api.shimli.app",
      "description": "Producción"
    }
  ],
  "tags": [
    {
      "name": "Agents",
      "description": "Gestión de agentes: crear, consultar y eliminar agentes del equipo."
    },
    {
      "name": "Contacts",
      "description": "Gestión de contactos y listas de distribución."
    },
    {
      "name": "Live Chat",
      "description": "Sesiones de chat en vivo y mensajería en tiempo real."
    },
    {
      "name": "WhatsApp Legacy",
      "description": "Mensajería WhatsApp por instancia QR (legacy)."
    },
    {
      "name": "Short Links",
      "description": "Acortador de URLs integrado."
    },
    {
      "name": "Shop",
      "description": "Catálogo de productos para comercio conversacional."
    },
    {
      "name": "Campaigns",
      "description": "Campañas de mensajería y reportes."
    },
    {
      "name": "Messaging",
      "description": "Envío de mensajes por WhatsApp Business API, Facebook Messenger y SMS, más CRM y validación."
    }
  ],
  "paths": {
    "/v1/agent": {
      "get": {
        "operationId": "get_agent",
        "tags": [
          "Agents"
        ],
        "summary": "Get Agent",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      },
      "post": {
        "operationId": "insert_agent",
        "tags": [
          "Agents"
        ],
        "summary": "Insert Agent",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "example": "Name_Agent"
                  },
                  "phone": {
                    "type": "string",
                    "example": "Number_Agent"
                  },
                  "email": {
                    "type": "string",
                    "example": "Email_Agent"
                  }
                },
                "required": [
                  "name",
                  "phone",
                  "email"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "token": "TOKEN_SHIMLI",
                    "name": "Name_Agent",
                    "phone": "Number_Agent",
                    "email": "Email_Agent"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      },
      "delete": {
        "operationId": "delete_agent",
        "tags": [
          "Agents"
        ],
        "summary": "Delete Agent",
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    },
    "/v1/contact": {
      "get": {
        "operationId": "get_contact",
        "tags": [
          "Contacts"
        ],
        "summary": "Get Contact",
        "description": "# Get a contact",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Id"
          }
        ],
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      },
      "post": {
        "operationId": "insert_contact",
        "tags": [
          "Contacts"
        ],
        "summary": "Insert Contact",
        "description": "# Adding a contact to a specific list\n\nImportant: ID_WHATSAPP must contain the following structure \"COUNTY_CODE\" + \"PHONE_NUMBER\" example 14243962506\n\nIn the value object, you need to send all the fields you want to enter the list",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idList": {
                    "type": "string",
                    "description": "Id list"
                  },
                  "values": {
                    "type": "object",
                    "properties": {
                      "phone": {
                        "type": "string",
                        "description": "Id whatsapp"
                      },
                      "name": {
                        "type": "string",
                        "description": "Name"
                      }
                    }
                  }
                },
                "required": [
                  "idList",
                  "values"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "token": "TOKEN_SHIMLI",
                    "idList": "ID_LIST",
                    "values": {
                      "phone": "ID_WHATSAPP",
                      "name": "NAME"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    },
    "/v1/live-chat/session": {
      "post": {
        "operationId": "create_live_chat_session",
        "tags": [
          "Live Chat"
        ],
        "summary": "Create Live Chat session",
        "description": "Optional parameters\n\n- name string = name of contact",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "instance": {
                    "type": "string",
                    "description": "Tu token de API de Shimli"
                  }
                },
                "required": [
                  "instance"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "token": "{{token}}",
                    "instance": "{{instance}}"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    },
    "/v1/live-chat": {
      "post": {
        "operationId": "send_live_chat_message",
        "tags": [
          "Live Chat"
        ],
        "summary": "Send Live Chat Message",
        "description": "Optional parameters\n\n- user boolean = true send by user, for defaul is false",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "example": "text"
                  },
                  "body": {
                    "type": "string",
                    "example": "Hi 👋!!"
                  },
                  "to": {
                    "type": "string",
                    "description": "Tu token de API de Shimli"
                  },
                  "instance": {
                    "type": "string",
                    "description": "Tu token de API de Shimli"
                  }
                },
                "required": [
                  "type",
                  "body",
                  "to",
                  "instance"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "token": "{{token}}",
                    "type": "text",
                    "body": "Hi 👋!!",
                    "to": "{{session}}",
                    "instance": "{{instance}}"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    },
    "/v1/msg-wh": {
      "post": {
        "operationId": "send_whatsapp_message",
        "tags": [
          "WhatsApp Legacy"
        ],
        "summary": "Send WhatsApp Message",
        "description": "TYPE_MESSAGE = [\"chat\", \"image\", \"video\", \"document\", \"audio\", \"gif\", \"location\", \"sticker\"]\n\nImportant: When sending a multimedia message (image, video, gif, audio, document) the body parameter must contain the URL of the file)\n\nOptional parameters\n- caption _string_ = Text when sending an image or video message\n- filename _string_ = Name of the document to send (only when it is a document type message)\n- lat _string_ = Latitude when it is a location type message\n- lng _string_ = Longitude when it is a location type message",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Tu token de API de Shimli"
                  },
                  "body": {
                    "type": "string",
                    "example": "Hi 👋!!"
                  },
                  "to": {
                    "type": "string",
                    "description": "Number whatsapp"
                  },
                  "instance": {
                    "type": "string",
                    "description": "Tu token de API de Shimli"
                  }
                },
                "required": [
                  "type",
                  "body",
                  "to",
                  "instance"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "token": "{{token}}",
                    "type": "{{type}}",
                    "body": "Hi 👋!!",
                    "to": "NUMBER_WHATSAPP",
                    "instance": "{{instance}}"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "statusCode": 200,
                  "body": {
                    "err": false
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/msg-wh/{ID_MESSAGE}": {
      "get": {
        "operationId": "get_whatsapp_message",
        "tags": [
          "WhatsApp Legacy"
        ],
        "summary": "Get WhatsApp Message",
        "parameters": [
          {
            "name": "ID_MESSAGE",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Id message"
          },
          {
            "name": "instance",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Instance"
          }
        ],
        "responses": {
          "200": {
            "description": "Respuesta exitosa",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "statusCode": 200,
                  "body": {
                    "err": false
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/short": {
      "post": {
        "operationId": "create_link_short_copy",
        "tags": [
          "Short Links"
        ],
        "summary": "Create Link Short Copy",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "longUrl": {
                    "type": "string",
                    "description": "Long url"
                  },
                  "idUrl": {
                    "type": "string",
                    "example": "ID (OPTIONAL)"
                  }
                },
                "required": [
                  "longUrl",
                  "idUrl"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "token": "TOKEN_SHIMLI",
                    "longUrl": "LONG_URL",
                    "idUrl": "ID (OPTIONAL)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      },
      "patch": {
        "operationId": "update_link_short",
        "tags": [
          "Short Links"
        ],
        "summary": "Update Link Short",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idUrl": {
                    "type": "string",
                    "description": "Id short link"
                  },
                  "longUrl": {
                    "type": "string",
                    "example": "NEW_URL_LONG"
                  }
                },
                "required": [
                  "idUrl",
                  "longUrl"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "idUrl": "ID_SHORT_LINK",
                    "token": "TOKEN_SHIMLI",
                    "longUrl": "NEW_URL_LONG"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    },
    "/v1/shop/products/ID_PRODUCT": {
      "get": {
        "operationId": "get_product",
        "tags": [
          "Shop"
        ],
        "summary": "Get Product",
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      },
      "put": {
        "operationId": "update_product",
        "tags": [
          "Shop"
        ],
        "summary": "Update Product",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "image": {
                    "type": "string",
                    "description": "Url image"
                  },
                  "name": {
                    "type": "string",
                    "description": "Name"
                  },
                  "description": {
                    "type": "string",
                    "example": ""
                  },
                  "descriptionai": {
                    "type": "string",
                    "example": ""
                  },
                  "price": {
                    "type": "number",
                    "example": 0.0
                  },
                  "category": {
                    "type": "array",
                    "items": {}
                  },
                  "status": {
                    "type": "number",
                    "example": 1
                  },
                  "code": {
                    "type": "string",
                    "example": ""
                  }
                },
                "required": [
                  "image",
                  "name",
                  "description",
                  "descriptionai",
                  "category",
                  "code"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "image": "URL_IMAGE",
                    "name": "NAME",
                    "description": "",
                    "descriptionai": "",
                    "price": 0.0,
                    "category": [],
                    "status": 1,
                    "code": ""
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      },
      "delete": {
        "operationId": "remove_product",
        "tags": [
          "Shop"
        ],
        "summary": "Remove Product",
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    },
    "/v1/shop/products": {
      "post": {
        "operationId": "create_product",
        "tags": [
          "Shop"
        ],
        "summary": "Create Product",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Name product"
                  },
                  "description": {
                    "type": "string",
                    "example": "DESCRIPTION_PRODUCT"
                  },
                  "descriptionai": {
                    "type": "string",
                    "example": ""
                  },
                  "code": {
                    "type": "string",
                    "example": ""
                  },
                  "price": {
                    "type": "number",
                    "example": 23.98
                  },
                  "category": {
                    "type": "array",
                    "items": {}
                  }
                },
                "required": [
                  "name",
                  "description",
                  "descriptionai",
                  "code",
                  "category"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "name": "NAME PRODUCT",
                    "description": "DESCRIPTION_PRODUCT",
                    "descriptionai": "",
                    "code": "",
                    "price": 23.98,
                    "category": []
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    },
    "/v1/campaigns": {
      "get": {
        "operationId": "campaigns",
        "tags": [
          "Campaigns"
        ],
        "summary": "Campaigns",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Page"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Limit"
          }
        ],
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    },
    "/v1/campaigns/ID_CAMPAIGN": {
      "get": {
        "operationId": "get_campaign",
        "tags": [
          "Campaigns"
        ],
        "summary": "Get Campaign",
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    },
    "/v1/campaigns/ID_CAMPAIGN/details": {
      "get": {
        "operationId": "get_details_of_campaign",
        "tags": [
          "Campaigns"
        ],
        "summary": "Get Details of Campaign",
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    },
    "/v1/whatsapp-api": {
      "post": {
        "operationId": "send_whatsapp_business_api",
        "tags": [
          "Messaging"
        ],
        "summary": "Send WhatsApp Business API",
        "description": "TYPE_MESSAGE = [\"text\", \"image\", \"video\", \"document\", \"audio\"]\n\nImportant: When sending a multimedia message (image, video, gif, audio, document) the body parameter must contain the URL of the file)\n\nOptional parameters\n- caption _string_ = Text when sending an image or video message",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "Tu token de API de Shimli"
                  },
                  "body": {
                    "type": "string",
                    "example": "Hi 👋!!"
                  },
                  "to": {
                    "type": "string",
                    "description": "Number whatsapp"
                  },
                  "instance": {
                    "type": "string",
                    "description": "Tu token de API de Shimli"
                  }
                },
                "required": [
                  "type",
                  "body",
                  "to",
                  "instance"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "token": "{{token}}",
                    "type": "{{type}}",
                    "body": "Hi 👋!!",
                    "to": "NUMBER_WHATSAPP",
                    "instance": "{{instance}}"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "statusCode": 200,
                  "body": {
                    "err": false
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/facebook/send-messenger": {
      "post": {
        "operationId": "send_facebook_messenger",
        "tags": [
          "Messaging"
        ],
        "summary": "Send Facebook Messenger",
        "description": "TYPE_MESSAGE = [\"text\", \"image\", \"video\", \"file\", \"audio\"]\n\nImportant: When sending a multimedia message (image, video, gif, audio, document) the body parameter must contain the URL of the file)\n\nOptional parameters\n- caption _string_ = Text when sending an image or video message",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "example": "TYPE_MESSAGE"
                  },
                  "body": {
                    "type": "string",
                    "example": "Hi 👋!!"
                  },
                  "to": {
                    "type": "string",
                    "description": "Psid messenger"
                  },
                  "instance": {
                    "type": "string",
                    "description": "Id instance"
                  }
                },
                "required": [
                  "type",
                  "body",
                  "to",
                  "instance"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "token": "TOKEN_SHIMLI",
                    "type": "TYPE_MESSAGE",
                    "body": "Hi 👋!!",
                    "to": "PSID_MESSENGER",
                    "instance": "ID_INSTANCE"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    },
    "/v1/sms": {
      "post": {
        "operationId": "send_sms",
        "tags": [
          "Messaging"
        ],
        "summary": "Send SMS",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "example": "text"
                  },
                  "body": {
                    "type": "string",
                    "example": "Hi 👋!!"
                  },
                  "to": {
                    "type": "string",
                    "description": "Phone number"
                  },
                  "instance": {
                    "type": "string",
                    "description": "Tu token de API de Shimli"
                  }
                },
                "required": [
                  "type",
                  "body",
                  "to",
                  "instance"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "token": "{{token}}",
                    "type": "text",
                    "body": "Hi 👋!!",
                    "to": "PHONE_NUMBER",
                    "instance": "{{instance}}"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    },
    "/v1/crm": {
      "post": {
        "operationId": "lead_to_crm",
        "tags": [
          "Messaging"
        ],
        "summary": "Lead to CRM",
        "description": "# Lead injection in CRM\n\nImportant: ID_WHATSAPP must contain the following structure \"COUNTY_CODE\" + \"PHONE_NUMBER\" + \"@c.us\" example 14243962506@c.us\n\nOptional parameters\n- area _string_ = Area or equipment code\n- agent _string_ = Agent ID, for this to be possible you must send an area to which the agent belongs\n- process _string_ = Process ID\n- tags _string_ = example [\"customer service\", \"sales\"]\n- channel _string_ = whatsapp or fb-messenger",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "to": {
                    "type": "string",
                    "description": "Id contact"
                  },
                  "instance": {
                    "type": "string",
                    "description": "Id instance"
                  },
                  "text": {
                    "type": "string",
                    "example": "Open from API"
                  },
                  "area": {
                    "type": "string",
                    "description": "Id area"
                  },
                  "channel": {
                    "type": "string",
                    "description": "Id channel"
                  }
                },
                "required": [
                  "to",
                  "instance",
                  "text",
                  "area",
                  "channel"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "to": "ID_CONTACT",
                    "instance": "ID_INSTANCE",
                    "text": "Open from API",
                    "token": "TOKEN_SHIMLI",
                    "area": "ID_AREA",
                    "channel": "ID_CHANNEL"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    },
    "/v1/valid-whatsapp": {
      "post": {
        "operationId": "valid_whatsapp_number",
        "tags": [
          "Messaging"
        ],
        "summary": "Valid WhatsApp Number",
        "description": "Method that verifies if a number has WhatsApp active",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "instance": {
                    "type": "string",
                    "description": "Instance shimli"
                  },
                  "number": {
                    "type": "string",
                    "description": "Number whatsapp"
                  }
                },
                "required": [
                  "instance",
                  "number"
                ]
              },
              "examples": {
                "default": {
                  "value": {
                    "token": "TOKEN_SHIMLI",
                    "instance": "INSTANCE_SHIMLI",
                    "number": "NUMBER_WHATSAPP"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Respuesta exitosa",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {
                  "statusCode": 200,
                  "body": {
                    "err": false,
                    "response": {
                      "id": "1234567890@c.us",
                      "status": 404,
                      "isBusiness": false,
                      "canReceiveMessage": false
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/client": {
      "get": {
        "operationId": "get_client",
        "tags": [
          "Messaging"
        ],
        "summary": "Get Client",
        "responses": {
          "200": {
            "description": "Respuesta exitosa"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "tokenAuth": {
        "type": "apiKey",
        "in": "query",
        "name": "token",
        "description": "Token de API de Shimli."
      }
    }
  }
}
