# Create or replace settlement scheduler
URL: /api-reference/accounts/settlement-scheduler/upsert-settlement-scheduler

Creates or replaces the settlement scheduler of the specified Volt account. The whole configuration is replaced.

- `PUT /accounts/{accountId}/settlement-scheduler`

```json
{
  "servers": [
    {
      "url": "https://accounts.sandbox.volt.io",
      "description": "Sandbox"
    },
    {
      "url": "https://accounts.volt.io",
      "description": "Production"
    }
  ],
  "paths": {
    "/accounts/{accountId}/settlement-scheduler": {
      "put": {
        "tags": [
          "Settlement scheduler"
        ],
        "summary": "Create or replace settlement scheduler",
        "operationId": "upsert-settlement-scheduler",
        "parameters": [
          {
            "$ref": "#/components/parameters/XVoltApiVersion"
          },
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Unique identifier of the Volt account the funds are settled from."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertSettlementSchedulerRequest"
              },
              "examples": {
                "dailyExample": {
                  "$ref": "#/components/examples/UpsertSettlementSchedulerDailyExample"
                },
                "mixedRulesWithThresholdExample": {
                  "$ref": "#/components/examples/UpsertSettlementSchedulerMixedRulesExample"
                }
              }
            }
          }
        },
        "responses": {
          "204": {
            "description": "Settlement scheduler stored."
          },
          "400": {
            "$ref": "#/components/responses/400"
          },
          "401": {
            "$ref": "#/components/responses/401"
          },
          "403": {
            "$ref": "#/components/responses/403"
          },
          "404": {
            "$ref": "#/components/responses/404"
          },
          "415": {
            "$ref": "#/components/responses/415"
          },
          "422": {
            "$ref": "#/components/responses/422"
          },
          "500": {
            "$ref": "#/components/responses/500"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "parameters": {
      "XVoltApiVersion": {
        "name": "X-Volt-Api-Version",
        "in": "header",
        "description": "Version of the API used. Currently, version `1` is the only version.",
        "required": true,
        "schema": {
          "type": "integer",
          "enum": [
            1
          ],
          "examples": [
            1
          ]
        }
      }
    },
    "schemas": {
      "UpsertSettlementSchedulerRequest": {
        "type": "object",
        "required": [
          "trustedAccountId",
          "active",
          "rules"
        ],
        "properties": {
          "trustedAccountId": {
            "type": "string",
            "format": "uuid",
            "description": "Id of the trusted account the funds are settled to. Must be active and belong to the owner of the account.",
            "examples": [
              "efffed42-40f7-4bd2-840d-908aae9a33ad"
            ]
          },
          "active": {
            "type": "boolean",
            "description": "Whether the scheduler triggers settlements. An inactive scheduler keeps its configuration."
          },
          "rules": {
            "type": "array",
            "minItems": 1,
            "maxItems": 50,
            "description": "Schedule rules. Rules of different types can be combined.",
            "items": {
              "$ref": "#/components/schemas/SettlementSchedulerRule"
            }
          },
          "threshold": {
            "$ref": "#/components/schemas/SettlementSchedulerThreshold"
          }
        }
      },
      "SettlementSchedulerRule": {
        "description": "A single schedule rule. The `type` property determines which other properties are required.",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/SettlementSchedulerRuleType"
          }
        },
        "oneOf": [
          {
            "$ref": "#/components/schemas/DailySettlementSchedulerRule"
          },
          {
            "$ref": "#/components/schemas/WeeklySettlementSchedulerRule"
          },
          {
            "$ref": "#/components/schemas/MonthlySettlementSchedulerRule"
          }
        ],
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "DAILY": "#/components/schemas/DailySettlementSchedulerRule",
            "WEEKLY": "#/components/schemas/WeeklySettlementSchedulerRule",
            "MONTHLY": "#/components/schemas/MonthlySettlementSchedulerRule"
          }
        }
      },
      "SettlementSchedulerRuleType": {
        "type": "string",
        "description": "Type of the schedule rule.",
        "enum": [
          "DAILY",
          "WEEKLY",
          "MONTHLY"
        ]
      },
      "DailySettlementSchedulerRule": {
        "type": "object",
        "description": "Settles every day at the given time.",
        "required": [
          "type",
          "timeOfDay"
        ],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/SettlementSchedulerRuleType"
          },
          "timeOfDay": {
            "type": "string",
            "description": "Time of day in UTC, in HH:mm format (00:00–23:59). Does not follow daylight saving time.",
            "examples": [
              "14:00"
            ]
          }
        }
      },
      "WeeklySettlementSchedulerRule": {
        "type": "object",
        "description": "Settles every week on the given day at the given time.",
        "required": [
          "type",
          "dayOfWeek",
          "timeOfDay"
        ],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/SettlementSchedulerRuleType"
          },
          "dayOfWeek": {
            "type": "string",
            "description": "Day of the week.",
            "enum": [
              "MONDAY",
              "TUESDAY",
              "WEDNESDAY",
              "THURSDAY",
              "FRIDAY",
              "SATURDAY",
              "SUNDAY"
            ]
          },
          "timeOfDay": {
            "$ref": "#/components/schemas/DailySettlementSchedulerRule/properties/timeOfDay"
          }
        }
      },
      "MonthlySettlementSchedulerRule": {
        "type": "object",
        "description": "Settles every month on the given day at the given time.",
        "required": [
          "type",
          "dayOfMonth",
          "timeOfDay"
        ],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/SettlementSchedulerRuleType"
          },
          "dayOfMonth": {
            "type": "integer",
            "minimum": 1,
            "maximum": 31,
            "description": "Day of the month. In shorter months, the last day of the month is used.",
            "examples": [
              15
            ]
          },
          "timeOfDay": {
            "$ref": "#/components/schemas/DailySettlementSchedulerRule/properties/timeOfDay"
          }
        }
      },
      "SettlementSchedulerThreshold": {
        "type": "object",
        "description": "Minimum available balance required to trigger a settlement.",
        "required": [
          "amount"
        ],
        "properties": {
          "amount": {
            "type": "integer",
            "format": "int64",
            "minimum": 1,
            "description": "Minimum available balance, in minor units of the account currency (e.g. 10000 for 100.00 EUR).",
            "examples": [
              10000
            ]
          }
        }
      },
      "Error400Response": {
        "type": "object",
        "description": "Error response for HTTP 400 Bad Request.",
        "properties": {
          "code": {
            "type": "string",
            "description": "Error code.",
            "enum": [
              "BAD_REQUEST",
              "INVALID_PATH_VARIABLE",
              "MISSING_HTTP_HEADER",
              "INVALID_HTTP_HEADER",
              "MALFORMED_PATH_PARAM",
              "MISSING_QUERY_PARAM",
              "INVALID_QUERY_PARAM",
              "MALFORMED_QUERY_PARAM",
              "CONFIGURATION_ERROR"
            ]
          },
          "message": {
            "type": "string",
            "description": "Error message."
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "Error401Response": {
        "type": "object",
        "description": "Error response for HTTP 401 Unauthorized.",
        "properties": {
          "code": {
            "type": "string",
            "description": "Error code.",
            "enum": [
              "UNAUTHORISED"
            ]
          },
          "message": {
            "type": "string",
            "description": "Error message."
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "Error403Response": {
        "type": "object",
        "description": "Error response for HTTP 403 Forbidden.",
        "properties": {
          "code": {
            "type": "string",
            "description": "Error code.",
            "enum": [
              "ACCESS_DENIED"
            ]
          },
          "message": {
            "type": "string",
            "description": "Error message."
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "Error404Response": {
        "type": "object",
        "description": "Error response for HTTP 404 Not Found.",
        "properties": {
          "code": {
            "type": "string",
            "description": "Error code.",
            "enum": [
              "RESOURCE_NOT_FOUND"
            ]
          },
          "message": {
            "type": "string",
            "description": "Error message."
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "Error415Response": {
        "type": "object",
        "description": "Request contains data in an unsupported content type.",
        "properties": {
          "code": {
            "type": "string",
            "description": "Error code.",
            "enum": [
              "UNSUPPORTED_MEDIA_TYPE"
            ]
          },
          "message": {
            "type": "string",
            "description": "Error message."
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "Error422Response": {
        "type": "object",
        "description": "Error response for HTTP 422 Unprocessable Entity.",
        "properties": {
          "code": {
            "type": "string",
            "description": "Error code.",
            "enum": [
              "VALIDATION_FAILURE"
            ]
          },
          "message": {
            "type": "string",
            "description": "Error message."
          },
          "errors": {
            "type": "array",
            "description": "Field validation errors.",
            "items": {
              "$ref": "#/components/schemas/ValidationErrorDetail"
            }
          }
        },
        "required": [
          "code",
          "message",
          "errors"
        ]
      },
      "ValidationErrorDetail": {
        "type": "object",
        "description": "Details about a specific validation error.",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/ValidationErrorType"
          },
          "propertyPath": {
            "type": "string",
            "description": "Points to the specific field or property in the incoming request that violated the validation rule."
          },
          "message": {
            "type": "string",
            "description": "Human-readable message about constraint violation."
          }
        }
      },
      "ValidationErrorType": {
        "type": "string",
        "description": "Type (code) of the constraint that was violated.\nList of types can be found in [here](https://docs.volt.io/implementation/essentials/error-handling#validation-error-types).",
        "enum": [
          "TOO_FEW",
          "TOO_MANY",
          "TOO_LOW",
          "TOO_HIGH",
          "TOO_SHORT",
          "TOO_LONG",
          "NOT_EQUAL",
          "IS_EQUAL",
          "INVALID_FORMAT",
          "INVALID_DATE",
          "INVALID_TIME",
          "INVALID_TYPE",
          "REGEX_FAILED",
          "OUT_OF_RANGE",
          "CHECKSUM_FAILED",
          "NOT_UNIQUE",
          "VALUE_REQUIRED",
          "INVALID_VALUE",
          "MISSING_FIELD",
          "FIELD_NOT_ALLOWED"
        ]
      },
      "Error500Response": {
        "type": "object",
        "description": "Error response for HTTP 500 Internal Server Error.",
        "properties": {
          "code": {
            "type": "string",
            "description": "Error code.",
            "enum": [
              "INTERNAL_SERVER_ERROR"
            ]
          },
          "message": {
            "type": "string",
            "description": "Error message."
          }
        },
        "required": [
          "code",
          "message"
        ]
      }
    },
    "examples": {
      "UpsertSettlementSchedulerDailyExample": {
        "summary": "Daily settlement",
        "value": {
          "trustedAccountId": "efffed42-40f7-4bd2-840d-908aae9a33ad",
          "active": true,
          "rules": [
            {
              "type": "DAILY",
              "timeOfDay": "16:00"
            }
          ]
        }
      },
      "UpsertSettlementSchedulerMixedRulesExample": {
        "summary": "Weekly and monthly settlements above a threshold",
        "value": {
          "trustedAccountId": "efffed42-40f7-4bd2-840d-908aae9a33ad",
          "active": true,
          "rules": [
            {
              "type": "WEEKLY",
              "dayOfWeek": "FRIDAY",
              "timeOfDay": "09:00"
            },
            {
              "type": "MONTHLY",
              "dayOfMonth": 31,
              "timeOfDay": "06:00"
            }
          ],
          "threshold": {
            "amount": 1000000
          }
        }
      }
    },
    "responses": {
      "400": {
        "description": "**Bad request** - Request you sent is invalid or malformed. Response will contain a description of the actual problem.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error400Response"
            }
          }
        }
      },
      "401": {
        "description": "**Unauthorized** - Your credentials were invalid. It may be that the token you've used has expired. Try re-authenticating with valid or updated credentials and retry this request.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error401Response"
            }
          }
        }
      },
      "403": {
        "description": "**Access denied** - Although your credentials are correct, your access to this section of the API has been disabled or limited. Subsequent requests to this endpoint will not be processed.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error403Response"
            }
          }
        }
      },
      "404": {
        "description": "**Not found** - The resource that you are requesting cannot be found.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error404Response"
            }
          }
        }
      },
      "415": {
        "description": "**Unsupported media-type** - Request contains data in an unsupported content type.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error415Response"
            }
          }
        }
      },
      "422": {
        "description": "**Unprocessable** - Request's payload validation fails.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error422Response"
            }
          }
        }
      },
      "500": {
        "description": "**Internal server error** - Something went wrong and request cannot be processed due to server error. Message will contain trace ID and timestamp, which allows to investigate what went wrong.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error500Response"
            }
          }
        }
      }
    }
  }
}
```