{
    "paths": {
        "/api/v1/stores/{storeId}/rates/configuration": {
            "get": {
                "tags": [
                    "Stores (Rates Config)"
                ],
                "summary": "Get store rate settings",
                "parameters": [
                    {
                        "name": "storeId",
                        "in": "path",
                        "required": true,
                        "description": "The store to fetch",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "description": "View rate settings of the specified store",
                "operationId": "Stores_GetStoreRateConfiguration",
                "responses": {
                    "200": {
                        "description": "specified store rate settings",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/StoreRateConfiguration"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "If you are authenticated but forbidden to view the specified store"
                    },
                    "404": {
                        "description": "The key is not found for this store"
                    }
                },
                "security": [
                    {
                        "API_Key": [
                            "btcpay.store.canmodifystoresettings"
                        ],
                        "Basic": []
                    }
                ]
            },
            "put": {
                "tags": [
                    "Stores (Rates Config)"
                ],
                "parameters": [
                    {
                        "name": "storeId",
                        "in": "path",
                        "required": true,
                        "description": "The store to fetch",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "summary": "Update store rate settings",
                "description": "Update a store's rate settings",
                "operationId": "Stores_UpdateStoreRateConfiguration",
                "requestBody": {
                    "x-name": "request",
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/StoreRateConfiguration"
                            }
                        }
                    },
                    "required": true,
                    "x-position": 1
                },
                "responses": {
                    "200": {
                        "description": "The settings were updated",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/StoreRateConfiguration"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "A list of errors that occurred when updating the settings",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ValidationProblemDetails"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "If you are authenticated but forbidden to modify the store"
                    }
                },
                "security": [
                    {
                        "API_Key": [
                            "btcpay.store.canmodifystoresettings"
                        ],
                        "Basic": []
                    }
                ]
            }
        },
        "/api/v1/stores/{storeId}/rates/configuration/preview": {
            "post": {
                "tags": [
                    "Stores (Rates Config)"
                ],
                "parameters": [
                    {
                        "name": "storeId",
                        "in": "path",
                        "required": true,
                        "description": "The store to fetch",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "currencyPair",
                        "description": "The currency pairs to preview",
                        "in": "query",
                        "style": "form",
                        "explode": true,
                        "schema": {
                            "type": "array",
                            "nullable": true,
                            "items": {
                                "type": "string"
                            }
                        },
                        "x-position": 1
                    }
                ],
                "summary": "Preview rate configuration results",
                "description": "Preview rate configuration results before you set it on the store",
                "operationId": "Stores_PreviewStoreRateConfiguration",
                "requestBody": {
                    "x-name": "request",
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/StoreRateConfiguration"
                            }
                        }
                    },
                    "required": true,
                    "x-position": 1
                },
                "responses": {
                    "200": {
                        "description": "The settings were executed and a preview was returned",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "$ref": "#/components/schemas/StoreRateResult"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "A list of errors that occurred when previewing the settings",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ValidationProblemDetails"
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "If you are authenticated but forbidden to modify the store"
                    }
                },
                "security": [
                    {
                        "API_Key": [
                            "btcpay.store.canmodifystoresettings"
                        ],
                        "Basic": []
                    }
                ]
            }
        }
    },
    "components": {
        "schemas": {
            "StoreRateConfiguration": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                    "spread": {
                        "type": "string",
                        "description": "A spread applies to the rate fetched in `%`. Must be `>= 0` or `<= 100`"
                    },
                    "preferredSource": {
                        "type": "string",
                        "description": "If `isCustomerScript` is `false` affect use this source in the default's `effectiveScript`, if `isCustomerScript` is `false`, this setting is set to `null`. (See /misc/rate-sources for the available sources)"
                    },
                    "isCustomScript": {
                        "type": "boolean",
                        "description": "Whether to use `preferredSource` with default script or a custom `effectiveScript`."
                    },
                    "effectiveScript": {
                        "type": "string",
                        "description": "When `isCustomScript` is `true`, this represent the custom script used to calculate a currency pair's exchange rate. Else, it represent the script generated by the default rules and `preferredSource`."
                    }
                }
            },
            "StoreRateResult": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                    "currencyPair": {
                        "type": "string",
                        "example": "BTC_USD",
                        "description": "Currency pair in the format of `BTC_USD`"
                    },
                    "errors": {
                        "type": "array",
                        "nullable": true,
                        "items": {
                            "type": "string"
                        },
                        "description": "Errors relating to this currency pair fetching based on your config"
                    },
                    "rate": {
                        "type": "string",
                        "format": "decimal",
                        "example": "64392.23",
                        "description": "the rate fetched based on the currency pair"
                    }
                }
            }
        }
    },
    "tags": [
        {
            "name": "Stores (Rates Config)",
            "description": "Store Rates Config operations"
        }
    ]
}