{
  "swagger": "2.0",
  "info": {
    "title": "apaleo Account API",
    "description": "Manage accounts, subscriptions and more.",
    "version": "v1"
  },
  "paths": {
    "/account/v1/accounts/current": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Returns the current account.",
        "description": "Retrieves information about the current account.\u003Cbr\u003EYou need to be authorized (no particular scope required)\u003Cbr\u003EFor fine-grained clients, you must have this permission: \u0027core.current_account.read\u0027.",
        "operationId": "AccountAccountsCurrentGet",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "schema": {
              "$ref": "#/definitions/AccountModel"
            }
          },
          "404": {
            "description": "The Request-URI could not be found."
          },
          "400": {
            "description": "Bad request."
          },
          "401": {
            "description": "You are unauthorized."
          },
          "403": {
            "description": "Forbidden."
          },
          "499": {
            "description": "Client closed request."
          },
          "500": {
            "description": "An unexpected error occurred."
          },
          "503": {
            "description": "The server is currently unavailable. Please try later."
          },
          "422": {
            "description": "Validation errors in the request body or query params.",
            "schema": {
              "$ref": "#/definitions/MessageItemCollection"
            }
          }
        },
        "security": [
          {
            "oauth2": []
          }
        ]
      },
      "put": {
        "tags": [
          "Account"
        ],
        "summary": "Replaces an existing account.",
        "description": "Completely replaces an account with the new definition passed in. The old data will be lost.\u003Cbr\u003EYou must have this scope: \u0027account.manage\u0027.\u003Cbr\u003EFor fine-grained clients, you must have this permission: \u0027core.current_account.modify\u0027.",
        "operationId": "AccountAccountsCurrentPut",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "The definition of the account.",
            "required": true,
            "schema": {
              "$ref": "#/definitions/ReplaceAccountModel"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "The account has been replaced."
          },
          "404": {
            "description": "The Request-URI could not be found."
          },
          "415": {
            "description": "Unsupported media type."
          },
          "400": {
            "description": "Bad request."
          },
          "401": {
            "description": "You are unauthorized."
          },
          "403": {
            "description": "Forbidden."
          },
          "499": {
            "description": "Client closed request."
          },
          "500": {
            "description": "An unexpected error occurred."
          },
          "503": {
            "description": "The server is currently unavailable. Please try later."
          },
          "422": {
            "description": "Validation errors in the request body or query params.",
            "schema": {
              "$ref": "#/definitions/MessageItemCollection"
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "account.manage",
              "admin"
            ]
          }
        ]
      }
    },
    "/account/v1/accounts": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Returns all accounts.",
        "description": "Get the list of accounts.\u003Cbr\u003EYou must have this scope: \u0027accounts.read\u0027.\u003Cbr\u003EFor fine-grained clients, you must have this permission: \u0027core.accounts.read\u0027.",
        "operationId": "AccountAccountsGet",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "accountCodes",
            "description": "Filter result by requested codes",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Return all accounts.",
            "schema": {
              "$ref": "#/definitions/AccountListModel"
            }
          },
          "204": {
            "description": "There are no accounts found."
          },
          "404": {
            "description": "The Request-URI could not be found."
          },
          "400": {
            "description": "Bad request."
          },
          "401": {
            "description": "You are unauthorized."
          },
          "403": {
            "description": "Forbidden."
          },
          "499": {
            "description": "Client closed request."
          },
          "500": {
            "description": "An unexpected error occurred."
          },
          "503": {
            "description": "The server is currently unavailable. Please try later."
          },
          "422": {
            "description": "Validation errors in the request body or query params.",
            "schema": {
              "$ref": "#/definitions/MessageItemCollection"
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "accounts.read"
            ]
          }
        ]
      },
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Creates an account with an admin user.",
        "description": "Use this call to create a new account.\u003Cbr\u003EYou must have this scope: \u0027account.create\u0027.\u003Cbr\u003EFor fine-grained clients, you must have this permission: \u0027core.accounts.create\u0027.",
        "operationId": "AccountAccountsPost",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "description": "Unique key for safely retrying requests without accidentally performing the same operation twice. \nWe\u0027ll always send back the same response for requests made with the same key, \nand keys can\u0027t be reused with different request parameters. Keys expire after 24 hours.",
            "type": "string"
          },
          {
            "in": "body",
            "name": "body",
            "description": "The definition of the account.",
            "required": true,
            "schema": {
              "$ref": "#/definitions/CreateAccountModel"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Creation of the new account was successful.",
            "schema": {
              "$ref": "#/definitions/AccountCreatedModel"
            },
            "headers": {
              "Location": {
                "description": "The location of the created resource.",
                "type": "string"
              }
            }
          },
          "404": {
            "description": "The Request-URI could not be found."
          },
          "415": {
            "description": "Unsupported media type."
          },
          "400": {
            "description": "Bad request."
          },
          "401": {
            "description": "You are unauthorized."
          },
          "403": {
            "description": "Forbidden."
          },
          "499": {
            "description": "Client closed request."
          },
          "500": {
            "description": "An unexpected error occurred."
          },
          "503": {
            "description": "The server is currently unavailable. Please try later."
          },
          "422": {
            "description": "Validation errors in the request body or query params.",
            "schema": {
              "$ref": "#/definitions/MessageItemCollection"
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "account.create"
            ]
          }
        ]
      }
    },
    "/account/v1/account-actions/current/suspend": {
      "put": {
        "tags": [
          "AccountActions"
        ],
        "summary": "Suspend the account.",
        "description": "Suspends the current account.\nThis changes the account type to \u0027Suspended\u0027.\u003Cbr\u003EYou must have this scope: \u0027account.manage\u0027.\u003Cbr\u003EFor fine-grained clients, you must have this permission: \u0027core.current_account.suspend\u0027.",
        "operationId": "AccountAccount-actionsCurrentSuspendPut",
        "produces": [
          "application/json"
        ],
        "responses": {
          "204": {
            "description": "Suspension of the account was successful."
          },
          "404": {
            "description": "The Request-URI could not be found."
          },
          "400": {
            "description": "Bad request."
          },
          "401": {
            "description": "You are unauthorized."
          },
          "403": {
            "description": "Forbidden."
          },
          "499": {
            "description": "Client closed request."
          },
          "500": {
            "description": "An unexpected error occurred."
          },
          "503": {
            "description": "The server is currently unavailable. Please try later."
          },
          "422": {
            "description": "Validation errors in the request body or query params.",
            "schema": {
              "$ref": "#/definitions/MessageItemCollection"
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "account.manage",
              "admin"
            ]
          }
        ]
      }
    },
    "/account/v1/account-actions/current/set-live": {
      "put": {
        "tags": [
          "AccountActions"
        ],
        "summary": "Move the account to live.",
        "description": "Move the current account to live.\nThis changes the account type to \u0027Live\u0027.\u003Cbr\u003EYou must have this scope: \u0027account.manage\u0027.\u003Cbr\u003EFor fine-grained clients, you must have this permission: \u0027core.current_account.set_live\u0027.",
        "operationId": "AccountAccount-actionsCurrentSet-livePut",
        "produces": [
          "application/json"
        ],
        "responses": {
          "204": {
            "description": "Moving account to live was successful."
          },
          "404": {
            "description": "The Request-URI could not be found."
          },
          "400": {
            "description": "Bad request."
          },
          "401": {
            "description": "You are unauthorized."
          },
          "403": {
            "description": "Forbidden."
          },
          "499": {
            "description": "Client closed request."
          },
          "500": {
            "description": "An unexpected error occurred."
          },
          "503": {
            "description": "The server is currently unavailable. Please try later."
          },
          "422": {
            "description": "Validation errors in the request body or query params.",
            "schema": {
              "$ref": "#/definitions/MessageItemCollection"
            }
          }
        },
        "security": [
          {
            "oauth2": [
              "account.manage",
              "admin"
            ]
          }
        ]
      }
    }
  },
  "definitions": {
    "AccountCreatedModel": {
      "type": "object",
      "required": [
        "code"
      ],
      "properties": {
        "code": {
          "type": "string",
          "description": "Account code"
        }
      },
      "additionalProperties": false,
      "example": {
        "code": "DEMO"
      }
    },
    "AccountItemModel": {
      "type": "object",
      "required": [
        "code",
        "name",
        "type"
      ],
      "properties": {
        "code": {
          "type": "string",
          "description": "The code for the account that can be shown in reports and table views"
        },
        "name": {
          "type": "string",
          "description": "The name for the account, which usually should be the company name",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "description": "The description for the account",
          "x-nullable": true
        },
        "type": {
          "type": "string",
          "description": "Type of the account",
          "enum": [
            "Trial",
            "Live",
            "Suspended",
            "Development"
          ]
        }
      },
      "additionalProperties": false
    },
    "AccountListModel": {
      "type": "object",
      "required": [
        "accounts",
        "count"
      ],
      "properties": {
        "accounts": {
          "type": "array",
          "description": "List of accounts",
          "items": {
            "$ref": "#/definitions/AccountItemModel"
          }
        },
        "count": {
          "type": "integer",
          "description": "Total count of items",
          "format": "int64"
        }
      },
      "additionalProperties": false,
      "example": {
        "accounts": [
          {
            "code": "DEMO",
            "name": "Demo Account",
            "description": "This is the demo account",
            "type": "Trial"
          }
        ],
        "count": 0
      }
    },
    "AccountModel": {
      "type": "object",
      "required": [
        "code",
        "defaultLanguage",
        "name",
        "type"
      ],
      "properties": {
        "code": {
          "type": "string",
          "description": "The code for the account that can be shown in reports and table views"
        },
        "name": {
          "type": "string",
          "description": "The name for the account, which usually should be the company name",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "description": "The description for the account",
          "x-nullable": true
        },
        "defaultLanguage": {
          "type": "string",
          "description": "The default language two-letter language code (ISO Alpha-2) for the account"
        },
        "logoUrl": {
          "type": "string",
          "description": "The URL of the account logo",
          "x-nullable": true
        },
        "location": {
          "$ref": "#/definitions/AddressModel"
        },
        "type": {
          "type": "string",
          "description": "Type of the account",
          "enum": [
            "Trial",
            "Live",
            "Suspended",
            "Development"
          ]
        },
        "additionallySupportedCountries": {
          "type": "array",
          "description": "The list of supported countries\nallowed values: AD, AE, AL, AR, AU, AW, AZ, BG, BS, BW, CA, CR, CV, CZ, EE, GR, HR, HU, ID, IE, IT, IS, JP, KP, LI, LT, LU, MA, MC, MG, MT, MX, MY, NG, NO, NZ, PF, PH, PL, PT, RE, RS, SA, SE, SI, SK, TW, US, ZA",
          "items": {
            "type": "string"
          },
          "x-nullable": true
        }
      },
      "additionalProperties": false,
      "example": {
        "code": "DEMO",
        "name": "Demo Account",
        "description": "This is the demo account",
        "defaultLanguage": "en",
        "logoUrl": "logo.png",
        "location": {
          "addressLine1": "My Street 1",
          "postalCode": "12345",
          "city": "MyCity",
          "countryCode": "GB"
        },
        "type": "Trial",
        "additionallySupportedCountries": [
          "ES",
          "FR"
        ]
      }
    },
    "AddressModel": {
      "type": "object",
      "required": [
        "addressLine1",
        "city",
        "countryCode",
        "postalCode"
      ],
      "properties": {
        "addressLine1": {
          "type": "string",
          "minLength": 1
        },
        "addressLine2": {
          "type": "string",
          "x-nullable": true
        },
        "postalCode": {
          "type": "string",
          "minLength": 1
        },
        "city": {
          "type": "string",
          "minLength": 1
        },
        "regionCode": {
          "type": "string",
          "x-nullable": true
        },
        "countryCode": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "CreateAccountModel": {
      "type": "object",
      "required": [
        "defaultLanguage",
        "name",
        "type"
      ],
      "properties": {
        "code": {
          "type": "string",
          "description": "The code for the account that can be shown in reports and table views. If not set, random one will be generated",
          "maxLength": 10,
          "minLength": 3,
          "pattern": "^[a-zA-Z0-9_]*$",
          "x-nullable": true
        },
        "name": {
          "type": "string",
          "description": "The name for the account, which usually should be the company name",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "description": "The description for the account",
          "x-nullable": true
        },
        "defaultLanguage": {
          "type": "string",
          "description": "The default language code for the account",
          "maxLength": 2,
          "minLength": 2
        },
        "logoUrl": {
          "type": "string",
          "description": "The URL of the account logo",
          "x-nullable": true
        },
        "type": {
          "type": "string",
          "description": "Set the type of the account",
          "enum": [
            "Trial",
            "Live",
            "Suspended",
            "Development"
          ]
        },
        "location": {
          "$ref": "#/definitions/CreateAddressModel"
        }
      },
      "additionalProperties": false,
      "example": {
        "code": "DEMO",
        "name": "Demo Account",
        "description": "This is the demo account",
        "defaultLanguage": "en",
        "logoUrl": "logo.png",
        "type": "Trial",
        "location": {
          "addressLine1": "My Street 1",
          "postalCode": "12345",
          "city": "MyCity",
          "countryCode": "GB"
        }
      }
    },
    "CreateAddressModel": {
      "type": "object",
      "required": [
        "addressLine1",
        "city",
        "countryCode",
        "postalCode"
      ],
      "properties": {
        "addressLine1": {
          "type": "string",
          "minLength": 1
        },
        "addressLine2": {
          "type": "string",
          "x-nullable": true
        },
        "postalCode": {
          "type": "string",
          "minLength": 1
        },
        "city": {
          "type": "string",
          "minLength": 1
        },
        "regionCode": {
          "type": "string",
          "description": "The ISO 3166-2 code",
          "maxLength": 6,
          "minLength": 2,
          "x-nullable": true
        },
        "countryCode": {
          "type": "string",
          "description": "The country code, in ISO 3166-1 alpha-2 code",
          "maxLength": 2,
          "minLength": 2
        }
      },
      "additionalProperties": false
    },
    "MessageItemCollection": {
      "type": "object",
      "properties": {
        "messages": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "readOnly": true,
          "x-nullable": true
        }
      },
      "additionalProperties": false
    },
    "ReplaceAccountModel": {
      "type": "object",
      "description": "With this request you can modify an account",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "The name for the account, which usually should be the company name",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "description": "The description for the account",
          "x-nullable": true
        },
        "logoUrl": {
          "type": "string",
          "description": "The URL of the account logo",
          "x-nullable": true
        },
        "location": {
          "$ref": "#/definitions/CreateAddressModel"
        },
        "additionallySupportedCountries": {
          "type": "array",
          "description": "The list of supported countries",
          "items": {
            "type": "string"
          },
          "x-nullable": true
        }
      },
      "additionalProperties": false,
      "example": {
        "name": "Demo Account",
        "description": "This is the demo account",
        "logoUrl": "logo.png",
        "location": {
          "addressLine1": "My Street 1",
          "postalCode": "12345",
          "city": "MyCity",
          "countryCode": "GB"
        }
      }
    }
  },
  "securityDefinitions": {
    "oauth2": {
      "type": "oauth2",
      "flow": "implicit",
      "authorizationUrl": "https://identity.apaleo.com/connect/authorize",
      "scopes": {
        "admin": "Full access",
        "reservations.import": "Import reservations"
      }
    }
  },
  "tags": [
    {
      "name": "Account"
    },
    {
      "name": "AccountActions"
    }
  ]
}