---
agentTools:
  projectIndex: https://payment-orchestrator.readme.io/llms.txt
---

# Create a Workflow

Creates a new **Workflow** entity.

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "version": "v1",
    "title": "Orchestration API",
    "description": "The Orchestration API is a service that executes one or more business rules at runtime according to predefined workflows.\n"
  },
  "servers": [
    {
      "url": "http://sandbox-planet-oapi-269696318.eu-central-1.elb.amazonaws.com:8081/api",
      "description": "Orchestration API - Staging"
    },
    {
      "url": "http://orchestration-api-alb-18064633.eu-west-3.elb.amazonaws.com:8081/api",
      "description": "Orchestration API - Sandbox"
    },
    {
      "url": "http://localhost:8080/api",
      "description": "Orchestration API - Dev"
    }
  ],
  "security": [
    {
      "api-key": []
    }
  ],
  "tags": [
    {
      "name": "Workflows",
      "description": "Manage Workflows"
    }
  ],
  "paths": {
    "/v1/workflows": {
      "post": {
        "tags": [
          "Workflows"
        ],
        "summary": "Create a Workflow",
        "operationId": "create-workflow",
        "description": "Creates a new **Workflow** entity.\n",
        "responses": {
          "201": {
            "description": "The workflow was created successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Workflow"
                }
              }
            },
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri",
                  "description": "The location that can be accessed to retrieve the created workflow."
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateWorkflowRequest"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "BadRequest": {
        "description": "The request is invalid. The specific reason is returned in the response body.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "The requester is not authorized to access the resource.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        },
        "headers": {
          "WWW_Authenticate": {
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "InternalServerError": {
        "description": "The request is valid but the server could not process it. The specific reason is returned in the response body.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "api-key": {
        "type": "apiKey",
        "name": "API-KEY",
        "in": "header",
        "description": "The API Key to authorize requests."
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "An explanation of the problem that occurred when processing a request [RFC7807].",
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "description": "A URI reference [RFC3986] that identifies the problem type.  This specification encourages that, when dereferenced, it provide human-readable documentation for the problem type (e.g., using HTML [W3C.REC-html5-20141028]).  When this member is not present, its value is assumed to be \"about:blank\".\n",
            "example": "/problems/validation-failed"
          },
          "title": {
            "type": "string",
            "description": "A short, human-readable summary of the problem type.  It SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization (e.g., using proactive content negotiation; see [RFC7231], Section 3.4).",
            "example": "The validation for the request has produced errors."
          },
          "status": {
            "type": "integer",
            "description": "The HTTP status code ([RFC7231], Section 6) generated by the origin server for this occurrence of the problem. Optional field.",
            "example": 400
          },
          "detail": {
            "type": "string",
            "description": "A human-readable explanation specific to this occurrence of the problem.",
            "example": "The validation of the request failed on field(s) 'A'."
          },
          "errors": {
            "type": "array",
            "nullable": true,
            "description": "A collection of all errors that occurred when processing the request.",
            "items": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "description": "Represents a single error within the application.",
        "properties": {
          "code": {
            "type": "string",
            "nullable": true,
            "description": "The unique error code.",
            "example": "V1234"
          },
          "message": {
            "type": "string",
            "description": "A human-readable message that states the error.",
            "example": "Field A value must be between 1 and 20."
          }
        }
      },
      "CreateWorkflowRequest": {
        "type": "object",
        "description": "A schema used to create a new workflow.",
        "required": [
          "name",
          "rules",
          "scope"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the workflow. Can be any valid string.",
            "example": "My-Workflow-1"
          },
          "rules": {
            "type": "array",
            "description": "A collection of linked rules that make up the workflow. The first rule is the first one to be executed.",
            "items": {
              "$ref": "#/components/schemas/Rule"
            }
          },
          "scope": {
            "type": "string",
            "format": "uuid",
            "description": "The scope identifier that this workflow targets. This identifier must point to a valid, existing scope."
          }
        }
      },
      "Workflow": {
        "description": "Represents a workflow.",
        "allOf": [
          {
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid",
                "description": "The identifier of the workflow."
              }
            }
          },
          {
            "$ref": "#/components/schemas/CreateWorkflowRequest"
          }
        ]
      },
      "RuleType": {
        "type": "string",
        "enum": [
          "Conditional",
          "Assignment"
        ]
      },
      "Rule": {
        "type": "object",
        "description": "Represents a workflow rule.",
        "required": [
          "type",
          "name"
        ],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/RuleType"
          },
          "name": {
            "type": "string",
            "description": "The rule name. Can be any string.",
            "example": "BeautifulRule"
          }
        },
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "Conditional": "#/components/schemas/ConditionalRule",
            "Assignment": "#/components/schemas/AssignmentRule"
          }
        }
      },
      "ConditionalRule": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Rule"
          },
          {
            "type": "object",
            "description": "Represents a workflow conditional rule.",
            "required": [
              "field",
              "operation",
              "value",
              "onTrueRuleName",
              "onFalseRuleName"
            ],
            "properties": {
              "field": {
                "type": "string",
                "description": "The name of the field to evaluate.",
                "example": "amount"
              },
              "operation": {
                "type": "string",
                "description": "The name of the operation to compare the field and the value.",
                "example": "gt"
              },
              "value": {
                "type": "object",
                "description": "The value to compare the incoming field value to.",
                "example": 200
              },
              "onTrueRuleName": {
                "type": "string",
                "description": "The name of the rule to go to in case the condition is verified.",
                "example": "Rule-A"
              },
              "onFalseRuleName": {
                "type": "string",
                "description": "The name of the rule to go to in case the condition is not verified.",
                "example": "Rule-B"
              }
            }
          }
        ]
      },
      "AssignmentRule": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Rule"
          },
          {
            "type": "object",
            "description": "Represents a workflow output assignment rule.",
            "required": [
              "outputFields"
            ],
            "properties": {
              "outputFields": {
                "type": "array",
                "description": "A list containing the output field assignments. They must conform to the required output fields defined in the scope that the workflow containing this rule targets, meaning that this list must contain all required output fields, but may add additional ones not contained in the related scope.",
                "items": {
                  "type": "object",
                  "title": "OutputFieldAssignment",
                  "required": [
                    "outputFieldPath",
                    "outputFieldValue"
                  ],
                  "properties": {
                    "outputFieldPath": {
                      "type": "string",
                      "description": "The output field path that may be configured in the workflow scope.",
                      "example": "receiver"
                    },
                    "outputFieldValue": {
                      "type": "object",
                      "description": "The output field value to assign.",
                      "example": 1
                    }
                  }
                }
              }
            }
          }
        ]
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 99,
      "1": 152,
      "2": 73,
      "3": 33,
      "4": 56,
      "5": 133,
      "6": 176,
      "7": 0,
      "8": 100,
      "9": 168,
      "10": 2,
      "11": 8
    }
  }
}
```