> ## Documentation Index
> Fetch the complete documentation index at: https://developers.insuranceboosters.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Publicar automatización

> Publica el borrador actual como una versión inmutable.

Crea una versión a partir del borrador actual. Las ejecuciones usan la última versión publicada.

## Endpoint

```text theme={null}
POST /workflows/{workflowId}/publish
```

## Ejemplo de solicitud

```bash theme={null}
curl -X POST "https://api.insuranceboosters.com/api/v1/workflows/<workflow-id>/publish" \
  -H "x-ib-api-key: TU_API_KEY"
```

## Respuesta exitosa (`200`)

```json theme={null}
{
  "workflow": {
    "id": "<workflow-id>",
    "name": "Notificar pago recibido",
    "status": "disabled",
    "trigger": {
      "type": "webhook",
      "secret": "<webhook-secret>"
    },
    "steps": [],
    "publishedVersionId": "<version-id>",
    "latestVersionNumber": 1,
    "createdAt": 1720000000000,
    "lastUpdatedAt": 1720000000000
  },
  "versionId": "<version-id>"
}
```

Guarda `versionId` si necesitas auditar qué definición usó cada ejecución.

## Errores frecuentes

| HTTP  | Qué significa                | Qué hacer                |
| ----- | ---------------------------- | ------------------------ |
| `401` | API key inválida o faltante. | Verifica `x-ib-api-key`. |
| `404` | La automatización no existe. | Confirma `workflowId`.   |


## OpenAPI

````yaml openapi/automatizaciones-v1.yaml POST /workflows/{workflowId}/publish
openapi: 3.1.0
info:
  title: Insurance Boosters API — Automatizaciones
  version: 1.0.0
  description: >
    API pública para crear, publicar y ejecutar automatizaciones por webhook,
    cron o eventos de registros, y consultar sus versiones y ejecuciones.
  license:
    name: Propietaria
    url: https://insuranceboosters.com
servers:
  - url: https://api.insuranceboosters.com/api/v1
    description: Producción
security:
  - IbApiKey: []
tags:
  - name: Automatizaciones
    description: Definición, publicación y control de automatizaciones.
  - name: Versiones
    description: Instantáneas publicadas de una automatización.
  - name: Ejecuciones
    description: Historial y detalle de corridas.
  - name: Webhooks
    description: Disparo público de automatizaciones con trigger webhook.
paths:
  /workflows/{workflowId}/publish:
    post:
      tags:
        - Automatizaciones
      summary: Publicar automatización
      operationId: publishWorkflow
      parameters:
        - $ref: '#/components/parameters/WorkflowId'
      responses:
        '200':
          description: Instantánea publicada.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublishWorkflowResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  parameters:
    WorkflowId:
      name: workflowId
      in: path
      required: true
      description: Identificador de la automatización.
      schema:
        type: string
  schemas:
    PublishWorkflowResponse:
      type: object
      required:
        - workflow
        - versionId
      properties:
        workflow:
          $ref: '#/components/schemas/Workflow'
        versionId:
          type: string
    Workflow:
      type: object
      required:
        - id
        - name
        - status
        - trigger
        - steps
        - createdAt
        - lastUpdatedAt
      properties:
        id:
          type: string
        name:
          type: string
        status:
          $ref: '#/components/schemas/WorkflowStatus'
        trigger:
          $ref: '#/components/schemas/WorkflowTrigger'
        steps:
          type: array
          items:
            $ref: '#/components/schemas/WorkflowStep'
        publishedVersionId:
          type: string
        latestVersionNumber:
          type: integer
        cronState:
          type: object
          properties:
            lastFiredAt:
              type: integer
            nextDueAt:
              type: integer
        createdAt:
          type: integer
        lastUpdatedAt:
          type: integer
    AuthError:
      type: object
      properties:
        message:
          type: string
      required:
        - message
    Error:
      type: object
      properties:
        error:
          type: string
      required:
        - error
    WorkflowStatus:
      type: string
      enum:
        - enabled
        - disabled
    WorkflowTrigger:
      oneOf:
        - $ref: '#/components/schemas/WebhookTrigger'
        - $ref: '#/components/schemas/CronTrigger'
        - $ref: '#/components/schemas/DatabaseRecordCreatedTrigger'
        - $ref: '#/components/schemas/DatabaseRecordUpdatedTrigger'
    WorkflowStep:
      oneOf:
        - $ref: '#/components/schemas/BrowserUseStep'
        - $ref: '#/components/schemas/BrowserScriptStep'
        - $ref: '#/components/schemas/DelayStep'
        - $ref: '#/components/schemas/HttpStep'
        - $ref: '#/components/schemas/CodeStep'
    WebhookTrigger:
      type: object
      required:
        - type
      properties:
        type:
          type: string
          const: webhook
        secret:
          type: string
          description: Generado por la API. Úsalo solo en la URL del webhook.
    CronTrigger:
      type: object
      required:
        - type
        - cron
        - timezone
      properties:
        type:
          type: string
          const: cron
        cron:
          type: string
          description: Expresión cron de 5 campos.
          example: 0 9 * * *
        timezone:
          type: string
          example: America/Mexico_City
    DatabaseRecordCreatedTrigger:
      type: object
      required:
        - type
        - databaseId
      properties:
        type:
          type: string
          const: database_record_created
        databaseId:
          type: string
          description: >-
            Identificador del tablero cuyos registros activarán la
            automatización.
          example: <database-id>
    DatabaseRecordUpdatedTrigger:
      type: object
      required:
        - type
        - databaseId
      properties:
        type:
          type: string
          const: database_record_updated
        databaseId:
          type: string
          description: >-
            Identificador del tablero cuyos registros activarán la
            automatización.
          example: <database-id>
    BrowserUseStep:
      type: object
      additionalProperties: false
      required:
        - actionKey
        - task
        - resultSchema
        - wait
      properties:
        id:
          type: string
        name:
          type: string
        actionKey:
          type: string
          const: browser.use
        task:
          type: string
          minLength: 1
          maxLength: 20000
          description: Tarea para el navegador. Acepta plantillas {{...}}.
        resultSchema:
          type: object
          required:
            - type
          properties:
            type:
              type: string
              const: object
          additionalProperties: true
          description: JSON Schema del output esperado. No debe declarar _files.
        wait:
          type: object
          additionalProperties: false
          properties:
            initialDelaySeconds:
              type: integer
              minimum: 0
              maximum: 604800
              default: 30
            pollIntervalSeconds:
              type: integer
              minimum: 1
              maximum: 3600
              default: 15
            timeoutSeconds:
              type: integer
              minimum: 2
              maximum: 604800
              default: 3600
    BrowserScriptStep:
      type: object
      required:
        - actionKey
        - code
      properties:
        id:
          type: string
        name:
          type: string
        actionKey:
          type: string
          const: browser.script
        code:
          type: string
          minLength: 1
          maxLength: 100000
          description: JavaScript que dirige al agente de IA con el objeto `browser`.
        input:
          type: object
          additionalProperties: true
          description: Variables disponibles como `input.*`. Acepta plantillas {{...}}.
        timeoutMs:
          type: number
    DelayStep:
      type: object
      required:
        - actionKey
        - input
      properties:
        id:
          type: string
        name:
          type: string
        actionKey:
          type: string
          const: system.delay
        input:
          type: object
          required:
            - mode
            - amount
            - unit
          properties:
            mode:
              type: string
              enum:
                - duration
            amount:
              type: integer
              minimum: 1
            unit:
              type: string
              enum:
                - seconds
                - minutes
                - hours
                - days
    HttpStep:
      type: object
      required:
        - actionKey
        - input
      properties:
        id:
          type: string
        name:
          type: string
        actionKey:
          type: string
          const: http.request
        input:
          type: object
          required:
            - method
            - url
          properties:
            method:
              type: string
              enum:
                - GET
                - POST
                - PUT
                - PATCH
                - DELETE
            url:
              type: string
            headers:
              type: object
              additionalProperties:
                type: string
            query:
              type: object
              additionalProperties: true
            body: {}
    CodeStep:
      type: object
      required:
        - actionKey
        - code
      properties:
        id:
          type: string
        name:
          type: string
        actionKey:
          type: string
          const: code.javascript
        code:
          type: string
        input:
          type: object
          additionalProperties: true
        timeoutMs:
          type: number
  responses:
    Unauthorized:
      description: API key inválida o faltante.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AuthError'
          example:
            message: Invalid API key.
    NotFound:
      description: Recurso no encontrado.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Workflow not found.
    InternalError:
      description: Error inesperado.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    IbApiKey:
      type: apiKey
      in: header
      name: x-ib-api-key
      description: API key emitida por Insurance Boosters.

````