POST · Publier un brouillon

Workflows : Publier un brouillon. Paramètres, accès et exemples de réponse.

Rédigé par Red Blue

Mis à jour le

Workflows

POST /api/v1/workflows/publish

operationId : workflow_publish

Accès

Permission

Consentements OAuth

OAuth : délégation d’un équipier pour l’API

workflow.update

api:connect, workflow:write

KHONY_ORIGIN est l’origine HTTPS de votre application Khony, sans chemin final. Remplacez les identifiants de l’exemple par ceux de vos ressources autorisées. Les données de réponse ci-dessous illustrent le format ; elles ne sont pas le résultat d’un appel à votre organisation.

Paramètres et en-têtes

Nom

Emplacement

Requis

Type et contraintes

idempotency-key

header

Oui

string ; uuid

x-khony-confirmation

header

Non

string ; uuid

Champs du corps JSON

Nom

Emplacement

Requis

Type et contraintes

productId

JSON

Oui

string

draftId

JSON

Oui

string

expectedRevision

JSON

Oui

integer ; Minimum : 0 ; Maximum : 9007199254740991

Exemple de requête

Shell
curl --request POST "$KHONY_ORIGIN/api/v1/workflows/publish" \
  --header "Authorization: Bearer $KHONY_ACCESS_TOKEN" \
  --header 'idempotency-key: 0198f886-9f71-7000-8000-000000000010' \
  --header 'x-khony-confirmation: 0198f886-9f71-7000-8000-000000000011' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "productId": "product_01k3w8d7vhe008000000000001",
  "draftId": "workflow_draft_01k3w8d7vhe008000000000001",
  "expectedRevision": 0
}'
Shell

Réponse de succès · HTTP 200

JSON
{
  "data": {
    "published": true,
    "workflowId": "workflow_01k3w8d7vhe008000000000001",
    "workflowVersionId": "workflow_version_01k3w8d7vhe008000000000001",
    "version": 1,
    "status": "active"
  }
}
JSON
Schéma complet du corps JSON
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "productId": {
      "type": "string",
      "pattern": "^product_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
    },
    "draftId": {
      "type": "string",
      "pattern": "^workflow_draft_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
    },
    "expectedRevision": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "productId",
    "draftId",
    "expectedRevision"
  ],
  "additionalProperties": false
}
JSON
Schéma complet de la réponse
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "data": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "published": {
              "type": "boolean",
              "const": true
            },
            "workflowId": {
              "type": "string",
              "pattern": "^workflow_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
            },
            "workflowVersionId": {
              "type": "string",
              "pattern": "^workflow_version_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
            },
            "version": {
              "type": "integer",
              "exclusiveMinimum": 0,
              "maximum": 9007199254740991
            },
            "status": {
              "type": "string"
            }
          },
          "required": [
            "published",
            "workflowId",
            "workflowVersionId",
            "version",
            "status"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "published": {
              "type": "boolean",
              "const": false
            },
            "reason": {
              "type": "string"
            },
            "issues": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "severity": {
                    "type": "string",
                    "enum": [
                      "error",
                      "warning"
                    ]
                  },
                  "path": {
                    "type": "array",
                    "items": {
                      "type": [
                        "string",
                        "number"
                      ]
                    }
                  },
                  "canonicalPath": {
                    "type": "array",
                    "items": {
                      "type": [
                        "string",
                        "number"
                      ]
                    }
                  },
                  "message": {
                    "type": "string"
                  },
                  "edgeId": {
                    "type": "string"
                  },
                  "port": {
                    "type": "string"
                  },
                  "nodeId": {
                    "type": "string"
                  },
                  "stepId": {
                    "type": "string"
                  },
                  "kind": {
                    "type": "string"
                  }
                },
                "required": [
                  "code"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "published",
            "reason",
            "issues"
          ],
          "additionalProperties": false
        }
      ]
    }
  },
  "required": [
    "data"
  ],
  "additionalProperties": false
}
JSON

Refus et reprise

Les statuts documentés pour cette opération sont 400, 401, 402, 403, 404, 409, 428, 429, 500, 503. Identifiez la cause avec error.code et, lorsqu’il est présent, error.reason. Une réponse 409 peut demander une relecture de révision ou signaler une commande incompatible ; une réponse 428 demande une confirmation humaine. Ne rejouez une écriture que selon son contrat.

Notes du contrat
JSON
{
  "description": "Requires a dedicated API OAuth bearer for audience /api/v1, api:connect and the stated workflow scope, current organization/product consent and native human permissions. Organization keys and cookies are not accepted. Every admission consumes a product API request; native write billing checks apply. Send a stable UUID Idempotency-Key with exactly the same body on retry. Effects and the immutable receipt commit together. Changed payload or stale revision returns 409. Replays reauthorize the current human. Requires verified human confirmation bound by the common runtime to this action, inputs, command key and delegated session. A model boolean is not confirmation. Production gates, dynamic action permissions, entitlements, active quota and conversation ownership are native. Publication freezes a version and visual snapshot. published=false contains native issues and leaves the revision unpublished."
}
JSON