---
title: "Create a new workflow"
method: PUT
path: "/workflows"
tags: ["Workflows"]
---

# Create a new workflow

`PUT /workflows`

## Request body

- CreateWorkflowRequest
  - `id` string — The internal identifier of the schedule. Required only for updates.
  - `templateId` string — The internal id of the template to be used for defining the schedule. Can be used in place of defining individual events for a schedule; in this case, the events will be automatically copied from the template. This streamlines the process and ensures consistency across schedules.
  - `customerDetails` CustomerDetails — Customer details
    - `id` string, required — The ID of the customer
    - `name` string — The name of the customer
  - `invoiceDetails` InvoiceDetails — Invoice details response object.
    - `id` string — The internal id of the invoice
    - `invoiceNo` string — The number of the invoice. Unique value that can be used as idempotency key
    - `description` string — Short description of the invoice
    - `totalAmount` string — The invoice total amount. Includes tax amount, amount paid or reduced with credit notes)
    - `taxAmount` string — The invoice tax amount.
    - `dueAmount` string — The invoice amount due (remaining to be paid).
    - `creditNotesAmount` string — The total amount that is credited.
    - `dueDate` string, date-time — The due date of the invoice
    - `issueDate` string, date-time — The issue date date of the invoice
    - `creationTime` string, date-time — The date the invoice was created
    - `lastUpdatedTime` string, date-time — The date the invoice was last updated
    - `paidTime` string, date-time — The date the invoice was paid
    - `status` 'DRAFT' | 'UNPAID' | 'OVERDUE' | 'SCHEDULED' | 'SUBMITTED' | 'PAID' | 'VOID' | 'SETTLED' — The invoice status
    - `statusReasonCode` 'MISSING_PAYER_CONTACT_DETAILS' | 'PENDING_ACTIVATION' | 'PENDING_DD_MANDATE' | 'PENDING_DD_CAPABILITY' | 'MARKED_AS_PAID' | 'WORKFLOW_COMPLETED' | 'NOTIFICATION_DELIVERY_FAILED' | 'BULK_PRUNE' | 'STALE_DRAFT_CLEANUP' | 'OTHER' | 'DIRECT_DEBIT_MANDATE_BANK_ACCOUNT_CHANGED' — The reason as predefined code why the invoice is in a certain status
    - `statusReason` string — Custom details on why the invoice is in a certain status
    - `itemsTaxType` 'EXCLUSIVE' | 'INCLUSIVE' | 'NONE' — How tax is applied to line items from the invoice
    - `items` LineItemResponse[] — The list of items from the invoice
      - `id` string — The ID of the line item to update.
      - `description` string — The description of the item.
      - `quantity` number — The quantity of items.
      - `unitAmount` number — The price per unit of the item.
      - `taxRate` number — The tax rate percentage applied on the line item amount (quantity * unit amount).
      - `taxAmount` number — The tax amount added on top of the line item amount.
      - `totalAmount` number — The total price of the item.
      - `taxDetails` TaxDetailsResponse — The tax details response.
        - `id` string — The ID of the tax rate.
        - `rate` number — The actual rate value.
      - `accountDetails` AccountDetailsResponse — The account details response.
        - `id` string — The ID of the account code.
        - `code` string — The account code value.
      - `productDetails` ProductDetailsResponse — The product details response.
        - `id` string — The ID of the product.
        - `code` string — The product code value.
      - `externalData` LineItemExternalData[] — Information about this line item captured from external systems
        - `id` string — The ID from the external platform
        - `connectorType` 'XERO' | 'QUICKBOOKS' | 'PLATFORM' — The name of the platform for which this data is stored for.
        - `templateId` string — The template ID from external platform from which this line item is created. Cannot use both the template ID and the account code.
        - `accountCode` string — The account code from external platform from which this line item is created. Cannot use both the template ID and the account code.
        - `groupLineId` string — The ID of the external platform's group line this line item is a component of. Null when the line item does not belong to a group.
      - `trackingItems` TrackingItemDetailsResponse[] — The tracking items associated with this line item.
        - `id` string — The ID of the tracking item.
        - `name` string — The name of the tracking item.
    - `creditNotes` CreditNoteResponse[] — The list of credit notes from the invoice
      - `id` string — Credit note id.
      - `number` string — Credit note number.
      - `amount` number — Credit note amount.
      - `valueDate` string, date-time — Date when credit note was applied.
      - `externalData` CreditNoteExternalData[] — References about this credit note from external platforms Adfin integrates with. Such as ID etc
        - `connectorType` 'XERO' | 'QUICKBOOKS' | 'PLATFORM' — The name of the platform for which this data is stored for.
        - `id` string — ID of the Credit Note in the external platform
    - `fileSource` 'NONE' | 'FILE_UPLOAD' | 'EXTERNAL' | 'ADFIN' | 'PENDING_ADFIN' — The source of the file currently being served
    - `invoiceSource` 'FILE_UPLOAD' | 'MANUAL' | 'PR' | 'EXTERNAL' | 'SCHEDULE' | 'PLATFORM' — The source of the invoice
    - `externalData` InvoiceExternalData[] — References about this invoice from external platforms Adfin integrates with. Such as ID etc
      - `connectorType` 'XERO' | 'QUICKBOOKS' | 'PLATFORM' — The name of the platform for which this data is stored for.
      - `id` string — ID of the Invoice in the external platform
      - `brandingThemeId` string — ID of the branding theme the invoice uses in the external platform, if any.
  - `name` string — The name of the schedule to be created for the customer. It must contain only alphanumeric characters, and be limited to a maximum of 50 characters.
  - `type` 'ONE_TIME_PAYMENT' | 'DD_MANDATE_AUTHORISATION' | 'DD_PAYMENT' | 'CUSTOMER_STATEMENT', required — The type of the schedule to be created for the customer
  - `customMessage` string — The (optional) custom message to be added to notification
  - `events` EventRequest[] — A list of events that will occur as part of the schedule, applicable exclusively to a single customer
    - `frequency` Frequency
      - `timeUnit` 'MONTH, WEEK, DAY' — Time unit measurements used to define the frequency of events
      - `frequency` integer — The frequency of the time units
      - `dayOfMonth` integer — The specific day of the month designated for executing the event. Please note that short month handling is applicable; if the value is set to 29, 30, or 31, the execution will occur on the last day of the month when applicable
    - `duration` Duration
      - `startDate` string, date-time — The date when the event execution will begin
      - `endDate` string, date-time — The date on which the execution of the event will conclude
      - `maxNoOfExecutions` integer — The maximum allowable executions of an event
    - `trigger` RelativeDateTrigger
      - `days` integer — The number of days before/after sent date
      - `operator` 'ON' | 'AFTER' | 'BEFORE' — The operator used for determining the send date
      - `referenceDate` 'DUE_DATE' | 'SENT_DATE' | 'PAYMENT_DATE' — The reference date used for computing the date when to execute the workflow step
    - `relativeDateTrigger` RelativeDateTrigger
      - `days` integer — The number of days before/after sent date
      - `operator` 'ON' | 'AFTER' | 'BEFORE' — The operator used for determining the send date
      - `referenceDate` 'DUE_DATE' | 'SENT_DATE' | 'PAYMENT_DATE' — The reference date used for computing the date when to execute the workflow step
    - `ordinalWeekdayTrigger` OrdinalWeekdayTrigger
      - `ordinal` integer, required — The ordinal position of the weekday in the month (e.g., 1 for first, 2 for second, -1 for last)
      - `dayOfWeek` string, required — The day of the week (MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY)
    - `type` 'NO_ACTION' | 'SEND_NOTIFICATION' | 'MAKE_PAYMENT' | 'UPDATE_DIRECT_DEBIT_PAYMENTS' | 'SEND_DD_INVOICE_NOTICE' | 'SEND_DD_COLLECTION_NOTICE' | 'SEND_DD_SUCCESS_COLLECTION_NOTICE' | 'SEND_DD_FAILED_COLLECTION_NOTICE' | 'START_FALLBACK_WORKFLOW' | 'SEND_MANDATE_AUTHORISATION_NOTIFICATION' | 'CREATE_DD_MANDATE' | 'PREVIEW_CHARGE_DATE' | 'PREVIEW_PAYOUT_DATE' | 'SEND_CUSTOMER_STATEMENT_NOTIFICATION' — Attribute that specifies the type of event
    - `details` unknown
  - `settings` WorkflowSettingsRequest
    - `customerStatementSettings` CustomerStatementSettings
      - `minOutstandingBalance` number — Minimum total outstanding balance required for the customer to receive a statement. Statements are only sent when the customer's outstanding balance meets or exceeds this threshold.
      - `minOverdueDays` integer — Minimum number of days an invoice or payment request must be overdue before the statement is triggered. The statement is sent if at least one invoice or payment request has been overdue for this duration.

## Response `200`

The request was successful, resulting in the creation of one workflow.

- WorkflowResponse
  - `id` string, required — The internal id of the workflow created
  - `templateId` string — The internal id of the template used to define the workflow. This template id has been utilized to automatically copy events into the instance, streamlining the process and ensuring consistency throughout
  - `customerDetails` CustomerDetails — Customer details
    - `id` string, required — The ID of the customer
    - `name` string — The name of the customer
  - `invoiceDetails` InvoiceDetails — Invoice details response object.
    - `id` string — The internal id of the invoice
    - `invoiceNo` string — The number of the invoice. Unique value that can be used as idempotency key
    - `description` string — Short description of the invoice
    - `totalAmount` string — The invoice total amount. Includes tax amount, amount paid or reduced with credit notes)
    - `taxAmount` string — The invoice tax amount.
    - `dueAmount` string — The invoice amount due (remaining to be paid).
    - `creditNotesAmount` string — The total amount that is credited.
    - `dueDate` string, date-time — The due date of the invoice
    - `issueDate` string, date-time — The issue date date of the invoice
    - `creationTime` string, date-time — The date the invoice was created
    - `lastUpdatedTime` string, date-time — The date the invoice was last updated
    - `paidTime` string, date-time — The date the invoice was paid
    - `status` 'DRAFT' | 'UNPAID' | 'OVERDUE' | 'SCHEDULED' | 'SUBMITTED' | 'PAID' | 'VOID' | 'SETTLED' — The invoice status
    - `statusReasonCode` 'MISSING_PAYER_CONTACT_DETAILS' | 'PENDING_ACTIVATION' | 'PENDING_DD_MANDATE' | 'PENDING_DD_CAPABILITY' | 'MARKED_AS_PAID' | 'WORKFLOW_COMPLETED' | 'NOTIFICATION_DELIVERY_FAILED' | 'BULK_PRUNE' | 'STALE_DRAFT_CLEANUP' | 'OTHER' | 'DIRECT_DEBIT_MANDATE_BANK_ACCOUNT_CHANGED' — The reason as predefined code why the invoice is in a certain status
    - `statusReason` string — Custom details on why the invoice is in a certain status
    - `itemsTaxType` 'EXCLUSIVE' | 'INCLUSIVE' | 'NONE' — How tax is applied to line items from the invoice
    - `items` LineItemResponse[] — The list of items from the invoice
      - `id` string — The ID of the line item to update.
      - `description` string — The description of the item.
      - `quantity` number — The quantity of items.
      - `unitAmount` number — The price per unit of the item.
      - `taxRate` number — The tax rate percentage applied on the line item amount (quantity * unit amount).
      - `taxAmount` number — The tax amount added on top of the line item amount.
      - `totalAmount` number — The total price of the item.
      - `taxDetails` TaxDetailsResponse — The tax details response.
        - `id` string — The ID of the tax rate.
        - `rate` number — The actual rate value.
      - `accountDetails` AccountDetailsResponse — The account details response.
        - `id` string — The ID of the account code.
        - `code` string — The account code value.
      - `productDetails` ProductDetailsResponse — The product details response.
        - `id` string — The ID of the product.
        - `code` string — The product code value.
      - `externalData` LineItemExternalData[] — Information about this line item captured from external systems
        - `id` string — The ID from the external platform
        - `connectorType` 'XERO' | 'QUICKBOOKS' | 'PLATFORM' — The name of the platform for which this data is stored for.
        - `templateId` string — The template ID from external platform from which this line item is created. Cannot use both the template ID and the account code.
        - `accountCode` string — The account code from external platform from which this line item is created. Cannot use both the template ID and the account code.
        - `groupLineId` string — The ID of the external platform's group line this line item is a component of. Null when the line item does not belong to a group.
      - `trackingItems` TrackingItemDetailsResponse[] — The tracking items associated with this line item.
        - `id` string — The ID of the tracking item.
        - `name` string — The name of the tracking item.
    - `creditNotes` CreditNoteResponse[] — The list of credit notes from the invoice
      - `id` string — Credit note id.
      - `number` string — Credit note number.
      - `amount` number — Credit note amount.
      - `valueDate` string, date-time — Date when credit note was applied.
      - `externalData` CreditNoteExternalData[] — References about this credit note from external platforms Adfin integrates with. Such as ID etc
        - `connectorType` 'XERO' | 'QUICKBOOKS' | 'PLATFORM' — The name of the platform for which this data is stored for.
        - `id` string — ID of the Credit Note in the external platform
    - `fileSource` 'NONE' | 'FILE_UPLOAD' | 'EXTERNAL' | 'ADFIN' | 'PENDING_ADFIN' — The source of the file currently being served
    - `invoiceSource` 'FILE_UPLOAD' | 'MANUAL' | 'PR' | 'EXTERNAL' | 'SCHEDULE' | 'PLATFORM' — The source of the invoice
    - `externalData` InvoiceExternalData[] — References about this invoice from external platforms Adfin integrates with. Such as ID etc
      - `connectorType` 'XERO' | 'QUICKBOOKS' | 'PLATFORM' — The name of the platform for which this data is stored for.
      - `id` string — ID of the Invoice in the external platform
      - `brandingThemeId` string — ID of the branding theme the invoice uses in the external platform, if any.
  - `name` string — The name of the workflow created for the customer
  - `type` 'ONE_TIME_PAYMENT' | 'DD_MANDATE_AUTHORISATION' | 'DD_PAYMENT' | 'CUSTOMER_STATEMENT', required — Attribute that specifies the type of workflow
  - `state` 'DRAFT' | 'PENDING' | 'ACTIVE' | 'PAUSED' | 'COMPLETED' | 'TERMINATED', required — The current state of the workflow
  - `paymentInitiationDate` string, date-time — The payment initiation date of Auto Collect workflows
  - `creationTime` string, date-time, required — The creation time of the workflow
  - `lastUpdatedTime` string, date-time — Last time the workflow was updated
  - `events` EventResponse[] — The list of events that will occur as part of the workflow, applicable exclusively to a single customer
    - `id` string — The internal id of the created event
    - `frequency` Frequency
      - `timeUnit` 'MONTH, WEEK, DAY' — Time unit measurements used to define the frequency of events
      - `frequency` integer — The frequency of the time units
      - `dayOfMonth` integer — The specific day of the month designated for executing the event. Please note that short month handling is applicable; if the value is set to 29, 30, or 31, the execution will occur on the last day of the month when applicable
    - `duration` Duration
      - `startDate` string, date-time — The date when the event execution will begin
      - `endDate` string, date-time — The date on which the execution of the event will conclude
      - `maxNoOfExecutions` integer — The maximum allowable executions of an event
    - `trigger` RelativeDateTrigger
      - `days` integer — The number of days before/after sent date
      - `operator` 'ON' | 'AFTER' | 'BEFORE' — The operator used for determining the send date
      - `referenceDate` 'DUE_DATE' | 'SENT_DATE' | 'PAYMENT_DATE' — The reference date used for computing the date when to execute the workflow step
    - `relativeDateTrigger` RelativeDateTrigger
      - `days` integer — The number of days before/after sent date
      - `operator` 'ON' | 'AFTER' | 'BEFORE' — The operator used for determining the send date
      - `referenceDate` 'DUE_DATE' | 'SENT_DATE' | 'PAYMENT_DATE' — The reference date used for computing the date when to execute the workflow step
    - `ordinalWeekdayTrigger` OrdinalWeekdayTrigger
      - `ordinal` integer, required — The ordinal position of the weekday in the month (e.g., 1 for first, 2 for second, -1 for last)
      - `dayOfWeek` string, required — The day of the week (MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY)
    - `triggerDate` string, date-time — The event trigger date computed based on event execution configurations
    - `type` 'NO_ACTION' | 'SEND_NOTIFICATION' | 'MAKE_PAYMENT' | 'UPDATE_DIRECT_DEBIT_PAYMENTS' | 'SEND_DD_INVOICE_NOTICE' | 'SEND_DD_COLLECTION_NOTICE' | 'SEND_DD_SUCCESS_COLLECTION_NOTICE' | 'SEND_DD_FAILED_COLLECTION_NOTICE' | 'START_FALLBACK_WORKFLOW' | 'SEND_MANDATE_AUTHORISATION_NOTIFICATION' | 'CREATE_DD_MANDATE' | 'PREVIEW_CHARGE_DATE' | 'PREVIEW_PAYOUT_DATE' | 'SEND_CUSTOMER_STATEMENT_NOTIFICATION' — The type of event
    - `state` 'SCHEDULED' | 'ACTIVE' | 'PAUSED' | 'SKIPPED' | 'FAILED' | 'FINISHED' | 'INACTIVE' | 'DELETED' — The current state of the event
    - `details` unknown
  - `settings` ReminderSettingsResponse[] — The settings for reminders
    - `id` string — The internal id of the schedule setting
    - `entityId` string — The internal id of the entity for whom this schedule setting was created.
    - `entityType` 'INVOICE' | 'CUSTOMER' — Attribute that specifies the type of entity
    - `customerDetails` CustomerDetails — Customer details
      - `id` string, required — The ID of the customer
      - `name` string — The name of the customer
    - `creationTime` string, date-time — The creation time of the schedule setting
    - `lastUpdatedTime` string, date-time — Last time the schedule setting was updated
    - `startTime` string, date-time — The time when the schedule setting activates
    - `endTime` string, date-time — The time when the schedule setting expires
  - `workflowSettings` WorkflowSettingsResponse
    - `reminderSettings` ReminderSettingsResponse[] — Scheduled reminder configurations for invoices or customers, defining when automated reminders should be sent based on start and end times
      - `id` string — The internal id of the schedule setting
      - `entityId` string — The internal id of the entity for whom this schedule setting was created.
      - `entityType` 'INVOICE' | 'CUSTOMER' — Attribute that specifies the type of entity
      - `customerDetails` CustomerDetails — Customer details
        - `id` string, required — The ID of the customer
        - `name` string — The name of the customer
      - `creationTime` string, date-time — The creation time of the schedule setting
      - `lastUpdatedTime` string, date-time — Last time the schedule setting was updated
      - `startTime` string, date-time — The time when the schedule setting activates
      - `endTime` string, date-time — The time when the schedule setting expires
    - `customerStatementSettings` CustomerStatementSettings
      - `minOutstandingBalance` number — Minimum total outstanding balance required for the customer to receive a statement. Statements are only sent when the customer's outstanding balance meets or exceeds this threshold.
      - `minOverdueDays` integer — Minimum number of days an invoice or payment request must be overdue before the statement is triggered. The statement is sent if at least one invoice or payment request has been overdue for this duration.
  - `autopilotReasoning` string — The overall strategy reasoning provided by the LLM, present only for autopilot workflows

## Other responses

- `400` — There was an issue reading or understanding the request. Please ensure that it adheres to the required format and includes all necessary parameters.
- `401` — Authentication is required.
- `422` — A validation error occurred with the request.
- `500` — The server was unable to process the request.

---

[API](https://skmtc.dev/adfin/apis/adfin-api.md) · [All operations](https://skmtc.dev/adfin/apis/adfin-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/adfin/adfin-api/revisions/53d29f0850e0/schema)
